diff mbox series

[FFmpeg-devel,3/9] avformat/imfdec: Simplify get_next_track_with_minimum_timestamp()

Message ID 20240603021526.2372698-3-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel,1/9] avdevice/xcbgrab: Check sscanf() return | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Michael Niedermayer June 3, 2024, 2:15 a.m. UTC
This also makes the code more robust

Fixes: CID1512414 Uninitialized pointer read

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavformat/imfdec.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Pierre-Anthony Lemieux June 3, 2024, 4:26 a.m. UTC | #1
LGTM

On Sun, Jun 2, 2024 at 7:16 PM Michael Niedermayer
<michael@niedermayer.cc> wrote:
>
> This also makes the code more robust
>
> Fixes: CID1512414 Uninitialized pointer read
>
> Sponsored-by: Sovereign Tech Fund
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavformat/imfdec.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c
> index 32208f89ccd..a86b4763ff8 100644
> --- a/libavformat/imfdec.c
> +++ b/libavformat/imfdec.c
> @@ -695,12 +695,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
> --
> 2.45.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox series

Patch

diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c
index 32208f89ccd..a86b4763ff8 100644
--- a/libavformat/imfdec.c
+++ b/libavformat/imfdec.c
@@ -695,12 +695,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