]> git.sesse.net Git - ffmpeg/commitdiff
avformat/mpeg: Check avio_read() return value in get_pts()
authorMichael Niedermayer <michael@niedermayer.cc>
Fri, 14 Aug 2020 23:07:44 +0000 (01:07 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Tue, 18 Aug 2020 12:56:04 +0000 (14:56 +0200)
Found-by: Thierry Foucu <tfoucu@gmail.com>
Fixes: Use-of-uninitialized-value
Reviewed-by: Thierry Foucu <tfoucu@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/mpeg.c

index 265b2bd1adb9bf226def96215477854d1fb48c17..a5e17925ce67eac6913e154c8f2724a4843e1781 100644 (file)
@@ -147,9 +147,12 @@ static int mpegps_read_header(AVFormatContext *s)
 static int64_t get_pts(AVIOContext *pb, int c)
 {
     uint8_t buf[5];
+    int ret;
 
     buf[0] = c < 0 ? avio_r8(pb) : c;
-    avio_read(pb, buf + 1, 4);
+    ret = avio_read(pb, buf + 1, 4);
+    if (ret < 4)
+        return AV_NOPTS_VALUE;
 
     return ff_parse_pes_pts(buf);
 }