[FFmpeg-devel] [PATCH] avformat/utils: fix undefined behaviour

Paul B Mahol onemda at gmail.com
Sun Feb 14 23:09:23 EET 2021


Fixes following report:
libavformat/utils.c:1429:14: runtime error: applying zero offset to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior libavformat/utils.c:1429:14

Signed-off-by: Paul B Mahol <onemda at gmail.com>
---
 libavformat/utils.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 3e955b85bc..e4f100fda2 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1426,8 +1426,10 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt,
         pkt->pts = pkt->dts = AV_NOPTS_VALUE;
         pkt->pos = -1;
         /* increment read pointer */
-        data += len;
-        size -= len;
+        if (len > 0) {
+            data += len;
+            size -= len;
+        }
 
         got_output = !!out_pkt.size;
 
-- 
2.17.1



More information about the ffmpeg-devel mailing list