[FFmpeg-devel,v1,03/11] avformat/iff: fix memleak when get st->codecpar->extradata failed in iff_read_header

Submitted by Steven Liu on Oct. 9, 2019, 7:35 a.m.

Details

Message ID 20191009073530.4505-3-lq@chinaffmpeg.org
State Accepted
Commit 9f0b9ae8bd84b45dc8bc7bcb96607c2948d546d7
Headers show

Commit Message

Steven Liu Oct. 9, 2019, 7:35 a.m.
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 libavformat/iff.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Paul B Mahol Oct. 9, 2019, 7:39 a.m.
lgtm

On 10/9/19, Steven Liu <lq@chinaffmpeg.org> wrote:
> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> ---
>  libavformat/iff.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/iff.c b/libavformat/iff.c
> index f4d806b7b8..2a3729f97e 100644
> --- a/libavformat/iff.c
> +++ b/libavformat/iff.c
> @@ -529,8 +529,11 @@ static int iff_read_header(AVFormatContext *s)
>              st->codecpar->extradata      = av_malloc(data_size +
> IFF_EXTRA_VIDEO_SIZE + AV_INPUT_BUFFER_PADDING_SIZE);
>              if (!st->codecpar->extradata)
>                  return AVERROR(ENOMEM);
> -            if (avio_read(pb, st->codecpar->extradata +
> IFF_EXTRA_VIDEO_SIZE, data_size) < 0)
> +            if (avio_read(pb, st->codecpar->extradata +
> IFF_EXTRA_VIDEO_SIZE, data_size) < 0) {
> +                av_freep(&st->codecpar->extradata);
> +                st->codecpar->extradata_size = 0;
>                  return AVERROR(EIO);
> +            }
>              break;
>
>          case ID_BMHD:
> --
> 2.15.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".
Steven Liu Oct. 10, 2019, 2:27 a.m.
> 在 2019年10月9日,15:39,Paul B Mahol <onemda@gmail.com> 写道:
> 
> lgtm
pushed
> 
> On 10/9/19, Steven Liu <lq@chinaffmpeg.org> wrote:
>> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
>> ---
>> libavformat/iff.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>> 
>> diff --git a/libavformat/iff.c b/libavformat/iff.c
>> index f4d806b7b8..2a3729f97e 100644
>> --- a/libavformat/iff.c
>> +++ b/libavformat/iff.c
>> @@ -529,8 +529,11 @@ static int iff_read_header(AVFormatContext *s)
>>             st->codecpar->extradata      = av_malloc(data_size +
>> IFF_EXTRA_VIDEO_SIZE + AV_INPUT_BUFFER_PADDING_SIZE);
>>             if (!st->codecpar->extradata)
>>                 return AVERROR(ENOMEM);
>> -            if (avio_read(pb, st->codecpar->extradata +
>> IFF_EXTRA_VIDEO_SIZE, data_size) < 0)
>> +            if (avio_read(pb, st->codecpar->extradata +
>> IFF_EXTRA_VIDEO_SIZE, data_size) < 0) {
>> +                av_freep(&st->codecpar->extradata);
>> +                st->codecpar->extradata_size = 0;
>>                 return AVERROR(EIO);
>> +            }
>>             break;
>> 
>>         case ID_BMHD:
>> --
>> 2.15.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".
> _______________________________________________
> 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".

Thanks
Steven

Patch hide | download patch | download mbox

diff --git a/libavformat/iff.c b/libavformat/iff.c
index f4d806b7b8..2a3729f97e 100644
--- a/libavformat/iff.c
+++ b/libavformat/iff.c
@@ -529,8 +529,11 @@  static int iff_read_header(AVFormatContext *s)
             st->codecpar->extradata      = av_malloc(data_size + IFF_EXTRA_VIDEO_SIZE + AV_INPUT_BUFFER_PADDING_SIZE);
             if (!st->codecpar->extradata)
                 return AVERROR(ENOMEM);
-            if (avio_read(pb, st->codecpar->extradata + IFF_EXTRA_VIDEO_SIZE, data_size) < 0)
+            if (avio_read(pb, st->codecpar->extradata + IFF_EXTRA_VIDEO_SIZE, data_size) < 0) {
+                av_freep(&st->codecpar->extradata);
+                st->codecpar->extradata_size = 0;
                 return AVERROR(EIO);
+            }
             break;
 
         case ID_BMHD: