]> git.sesse.net Git - ffmpeg/commitdiff
avformat/utils: Fix undefined NULL + 0
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Sun, 14 Feb 2021 21:24:46 +0000 (22:24 +0100)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Sun, 14 Feb 2021 21:47:08 +0000 (22:47 +0100)
This is undefined behaviour in C, so use data = len ? data + len : data
instead of data += len. GCC optimizes the branch away in this case;
Clang unfortunately doesn't.

Fixes ticket #8592.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavformat/utils.c

index 3e955b85bc69f078c47a59be938176700c463499..cea6d4ca92d63657fcc4f39751eb479712abeaf9 100644 (file)
@@ -1426,7 +1426,7 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt,
         pkt->pts = pkt->dts = AV_NOPTS_VALUE;
         pkt->pos = -1;
         /* increment read pointer */
-        data += len;
+        data  = len ? data + len : data;
         size -= len;
 
         got_output = !!out_pkt.size;