diff mbox series

[FFmpeg-devel] avformat: Add check for ff_get_extradata

Message ID 20220222074953.2788880-1-jiasheng@iscas.ac.cn
State New
Headers show
Series [FFmpeg-devel] avformat: Add check for ff_get_extradata | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_armv7_RPi4 success Make finished
andriy/make_fate_armv7_RPi4 success Make fate finished
andriy/make_aarch64_jetson success Make finished
andriy/make_fate_aarch64_jetson success Make fate finished

Commit Message

Jiasheng Jiang Feb. 22, 2022, 7:49 a.m. UTC
As the potential failure of the memory allocation, the ff_get_extradata()
could return error if fails.
Therefore, it should be better to deal with the return value of the
ff_get_extradata() and return error if fails.

Fixes: 2d720069a9 ("avformat: add aix demuxer")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
 libavformat/aixdec.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Paul B Mahol Feb. 22, 2022, 8:10 a.m. UTC | #1
On Tue, Feb 22, 2022 at 8:50 AM Jiasheng Jiang <jiasheng@iscas.ac.cn> wrote:

> As the potential failure of the memory allocation, the ff_get_extradata()
> could return error if fails.
> Therefore, it should be better to deal with the return value of the
> ff_get_extradata() and return error if fails.
>


Not really necessary. Does not fix anything.


>
> Fixes: 2d720069a9 ("avformat: add aix demuxer")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
>  libavformat/aixdec.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/libavformat/aixdec.c b/libavformat/aixdec.c
> index 59c3d60da3..89f73b6913 100644
> --- a/libavformat/aixdec.c
> +++ b/libavformat/aixdec.c
> @@ -40,7 +40,7 @@ static int aix_read_header(AVFormatContext *s)
>      unsigned segment_list_offset = 0x20;
>      unsigned segment_list_entry_size = 0x10;
>      unsigned size;
> -    int i;
> +    int i, ret;
>
>      avio_skip(s->pb, 4);
>      first_offset = avio_rb32(s->pb) + 8;
> @@ -77,7 +77,9 @@ static int aix_read_header(AVFormatContext *s)
>          if (size <= 8)
>              return AVERROR_INVALIDDATA;
>          avio_skip(s->pb, 8);
> -        ff_get_extradata(s, s->streams[i]->codecpar, s->pb, size - 8);
> +        ret = ff_get_extradata(s, s->streams[i]->codecpar, s->pb, size -
> 8);
> +        if (ret < 0)
> +            return ret;
>      }
>
>      return 0;
> --
> 2.25.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/aixdec.c b/libavformat/aixdec.c
index 59c3d60da3..89f73b6913 100644
--- a/libavformat/aixdec.c
+++ b/libavformat/aixdec.c
@@ -40,7 +40,7 @@  static int aix_read_header(AVFormatContext *s)
     unsigned segment_list_offset = 0x20;
     unsigned segment_list_entry_size = 0x10;
     unsigned size;
-    int i;
+    int i, ret;
 
     avio_skip(s->pb, 4);
     first_offset = avio_rb32(s->pb) + 8;
@@ -77,7 +77,9 @@  static int aix_read_header(AVFormatContext *s)
         if (size <= 8)
             return AVERROR_INVALIDDATA;
         avio_skip(s->pb, 8);
-        ff_get_extradata(s, s->streams[i]->codecpar, s->pb, size - 8);
+        ret = ff_get_extradata(s, s->streams[i]->codecpar, s->pb, size - 8);
+        if (ret < 0)
+            return ret;
     }
 
     return 0;