From ae964c585160f11ad8e3ab5f651ac11c43455109 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 3 Jun 2024 00:16:18 +0200 Subject: [PATCH] avformat/imfdec: Simplify get_next_track_with_minimum_timestamp() This also makes the code more robust Fixes: CID1512414 Uninitialized pointer read Sponsored-by: Sovereign Tech Fund Reviewed-by: Pierre-Anthony Lemieux Signed-off-by: Michael Niedermayer (cherry picked from commit f10493f6fc2a79f706138d90420a4369b9655a47) Signed-off-by: Michael Niedermayer --- libavformat/imfdec.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c index 818b5e590b..10c16461e8 100644 --- a/libavformat/imfdec.c +++ b/libavformat/imfdec.c @@ -700,12 +700,9 @@ static int imf_read_header(AVFormatContext *s) static IMFVirtualTrackPlaybackCtx *get_next_track_with_minimum_timestamp(AVFormatContext *s) { IMFContext *c = s->priv_data; - IMFVirtualTrackPlaybackCtx *track; + IMFVirtualTrackPlaybackCtx *track = NULL; AVRational minimum_timestamp = av_make_q(INT32_MAX, 1); - if (!c->track_count) - return NULL; - for (uint32_t i = c->track_count; i > 0; i--) { av_log(s, AV_LOG_TRACE, "Compare track %d timestamp " AVRATIONAL_FORMAT " to minimum " AVRATIONAL_FORMAT