diff mbox series

[FFmpeg-devel] avformat/utils: Add av_assert1 to preclude NULL + len, len != 0

Message ID 20210214232043.431998-1-andreas.rheinhardt@gmail.com
State Accepted
Commit da857099e92fb7fede6d7b9e6b26879ce9c5a483
Headers show
Series [FFmpeg-devel] avformat/utils: Add av_assert1 to preclude NULL + len, len != 0 | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Feb. 14, 2021, 11:20 p.m. UTC
Such a scenario is undefined behaviour and would also indicate a bug
in our code.

Suggested-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/utils.c | 1 +
 1 file changed, 1 insertion(+)

Comments

James Almer Feb. 15, 2021, 3:13 p.m. UTC | #1
On 2/14/2021 8:20 PM, Andreas Rheinhardt wrote:
> Such a scenario is undefined behaviour and would also indicate a bug
> in our code.
> 
> Suggested-by: James Almer <jamrial@gmail.com>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>   libavformat/utils.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index cea6d4ca92..652758e98e 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -1426,6 +1426,7 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt,
>           pkt->pts = pkt->dts = AV_NOPTS_VALUE;
>           pkt->pos = -1;
>           /* increment read pointer */
> +        av_assert1(data || !len);
>           data  = len ? data + len : data;
>           size -= len;

LGTM.
diff mbox series

Patch

diff --git a/libavformat/utils.c b/libavformat/utils.c
index cea6d4ca92..652758e98e 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1426,6 +1426,7 @@  static int parse_packet(AVFormatContext *s, AVPacket *pkt,
         pkt->pts = pkt->dts = AV_NOPTS_VALUE;
         pkt->pos = -1;
         /* increment read pointer */
+        av_assert1(data || !len);
         data  = len ? data + len : data;
         size -= len;