[FFmpeg-devel] [PATCH v2] avformat/imfdec: check track valid before use it

Steven Liu lq at chinaffmpeg.org
Fri Aug 26 09:44:56 EEST 2022


fix CID: 1512414
And return AVERROR_INVALIDDATA when get_next_track_with_minimum_timestamp
incorrect in imf_read_packet;

Signed-off-by: Steven Liu <lq at chinaffmpeg.org>
---
 libavformat/imfdec.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c
index 5bbe7a53f8..08f342bc1a 100644
--- a/libavformat/imfdec.c
+++ b/libavformat/imfdec.c
@@ -697,8 +697,9 @@ static IMFVirtualTrackPlaybackCtx *get_next_track_with_minimum_timestamp(AVForma
         }
     }
 
-    av_log(s, AV_LOG_DEBUG, "Found next track to read: %d (timestamp: %lf / %lf)\n",
-           track->index, av_q2d(track->current_timestamp), av_q2d(minimum_timestamp));
+    if (track)
+        av_log(s, AV_LOG_DEBUG, "Found next track to read: %d (timestamp: %lf / %lf)\n",
+               track->index, av_q2d(track->current_timestamp), av_q2d(minimum_timestamp));
     return track;
 }
 
@@ -760,6 +761,8 @@ static int imf_read_packet(AVFormatContext *s, AVPacket *pkt)
     AVRational next_timestamp;
 
     track = get_next_track_with_minimum_timestamp(s);
+    if (!track)
+        return AVERROR_INVALIDDATA;
 
     ret = get_resource_context_for_timestamp(s, track, &resource);
     if (ret)
-- 
2.25.0



More information about the ffmpeg-devel mailing list