[FFmpeg-devel] [PATCH] lavc/smvjpegdec: fix mem leak in case of init failure

Lukasz Marek lukasz.m.luki2 at gmail.com
Sun Nov 23 22:10:10 CET 2014


On 23.11.2014 17:25, Michael Niedermayer wrote:
> On Sat, Nov 22, 2014 at 11:26:04PM +0100, Lukasz Marek wrote:
>> Signed-off-by: Lukasz Marek <lukasz.m.luki2 at gmail.com>
>> ---
>>   libavcodec/smvjpegdec.c | 9 ++++++++-
>>   1 file changed, 8 insertions(+), 1 deletion(-)
>>
>> diff --git a/libavcodec/smvjpegdec.c b/libavcodec/smvjpegdec.c
>> index 69327cd..261a441 100644
>> --- a/libavcodec/smvjpegdec.c
>> +++ b/libavcodec/smvjpegdec.c
>> @@ -89,8 +89,10 @@ static av_cold int smvjpeg_decode_init(AVCodecContext *avctx)
>>           return AVERROR(ENOMEM);
>>
>>       s->picture[1] = av_frame_alloc();
>> -    if (!s->picture[1])
>> +    if (!s->picture[1]) {
>> +        av_frame_free(&s->picture[0]);
>>           return AVERROR(ENOMEM);
>> +    }
>>
>>       s->jpg.picture_ptr      = s->picture[0];
>>
>> @@ -120,6 +122,11 @@ static av_cold int smvjpeg_decode_init(AVCodecContext *avctx)
>>       }
>>       av_dict_free(&thread_opt);
>>
>> +    if (ret < 0) {
>> +        av_frame_free(&s->picture[0]);
>> +        av_frame_free(&s->picture[1]);
>> +        avcodec_free_context(&s->avctx);
>> +    }
>>       return ret;
>>   }
>
> LGTM, alternatively smvjpeg_decode_end() could probably be called on
> error

Updated patch. The same comment as for huffyuvdec.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-lavc-smvjpegdec-fix-mem-leak-in-case-of-init-failure.patch
Type: text/x-patch
Size: 2317 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20141123/f6dc4768/attachment.bin>


More information about the ffmpeg-devel mailing list