diff mbox series

[FFmpeg-devel,03/25] avformat/yuv4mpegdec: Don't call avio_tell() twice

Message ID AM7PR03MB66603649E312770032D82EDA8FC89@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Commit 9abf0e0419c1ebfe6ba9075af0f032b6d45ef741
Headers show
Series [FFmpeg-devel,01/25] avformat/matroskadec: Fix heap-buffer overflow upon gigantic timestamps | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Andreas Rheinhardt Aug. 27, 2021, 2:27 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/yuv4mpegdec.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/yuv4mpegdec.c b/libavformat/yuv4mpegdec.c
index c327aa9d3f..69dd8a3165 100644
--- a/libavformat/yuv4mpegdec.c
+++ b/libavformat/yuv4mpegdec.c
@@ -44,6 +44,7 @@  static int yuv4_read_header(AVFormatContext *s)
     enum AVFieldOrder field_order = AV_FIELD_UNKNOWN;
     enum AVColorRange color_range = AVCOL_RANGE_UNSPECIFIED;
     AVStream *st;
+    int64_t data_offset;
 
     for (i = 0; i < MAX_YUV4_HEADER; i++) {
         header[i] = avio_r8(pb);
@@ -254,9 +255,9 @@  static int yuv4_read_header(AVFormatContext *s)
     s->packet_size = av_image_get_buffer_size(st->codecpar->format, width, height, 1) + Y4M_FRAME_MAGIC_LEN;
     if ((int) s->packet_size < 0)
         return s->packet_size;
-    s->internal->data_offset = avio_tell(pb);
+    s->internal->data_offset = data_offset = avio_tell(pb);
 
-    st->duration = (avio_size(pb) - avio_tell(pb)) / s->packet_size;
+    st->duration = (avio_size(pb) - data_offset) / s->packet_size;
 
     return 0;
 }