You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-07-11 14:30:22 +02:00
lavc/smvjpegdec: fix mem leak in case of init failure
Signed-off-by: Lukasz Marek <lukasz.m.luki2@gmail.com>
This commit is contained in:
@ -75,6 +75,20 @@ static inline void smv_img_pnt(uint8_t *dst_data[4], uint8_t *src_data[4],
|
|||||||
dst_data[1] = src_data[1];
|
dst_data[1] = src_data[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static av_cold int smvjpeg_decode_end(AVCodecContext *avctx)
|
||||||
|
{
|
||||||
|
SMVJpegDecodeContext *s = avctx->priv_data;
|
||||||
|
MJpegDecodeContext *jpg = &s->jpg;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
jpg->picture_ptr = NULL;
|
||||||
|
av_frame_free(&s->picture[0]);
|
||||||
|
av_frame_free(&s->picture[1]);
|
||||||
|
ret = avcodec_close(s->avctx);
|
||||||
|
av_freep(&s->avctx);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static av_cold int smvjpeg_decode_init(AVCodecContext *avctx)
|
static av_cold int smvjpeg_decode_init(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
SMVJpegDecodeContext *s = avctx->priv_data;
|
SMVJpegDecodeContext *s = avctx->priv_data;
|
||||||
@ -89,8 +103,10 @@ static av_cold int smvjpeg_decode_init(AVCodecContext *avctx)
|
|||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
s->picture[1] = av_frame_alloc();
|
s->picture[1] = av_frame_alloc();
|
||||||
if (!s->picture[1])
|
if (!s->picture[1]) {
|
||||||
|
av_frame_free(&s->picture[0]);
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
}
|
||||||
|
|
||||||
s->jpg.picture_ptr = s->picture[0];
|
s->jpg.picture_ptr = s->picture[0];
|
||||||
|
|
||||||
@ -120,6 +136,8 @@ static av_cold int smvjpeg_decode_init(AVCodecContext *avctx)
|
|||||||
}
|
}
|
||||||
av_dict_free(&thread_opt);
|
av_dict_free(&thread_opt);
|
||||||
|
|
||||||
|
if (ret < 0)
|
||||||
|
smvjpeg_decode_end(avctx);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,20 +194,6 @@ static int smvjpeg_decode_frame(AVCodecContext *avctx, void *data, int *data_siz
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static av_cold int smvjpeg_decode_end(AVCodecContext *avctx)
|
|
||||||
{
|
|
||||||
SMVJpegDecodeContext *s = avctx->priv_data;
|
|
||||||
MJpegDecodeContext *jpg = &s->jpg;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
jpg->picture_ptr = NULL;
|
|
||||||
av_frame_free(&s->picture[0]);
|
|
||||||
av_frame_free(&s->picture[1]);
|
|
||||||
ret = avcodec_close(s->avctx);
|
|
||||||
av_freep(&s->avctx);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const AVClass smvjpegdec_class = {
|
static const AVClass smvjpegdec_class = {
|
||||||
.class_name = "SMVJPEG decoder",
|
.class_name = "SMVJPEG decoder",
|
||||||
.item_name = av_default_item_name,
|
.item_name = av_default_item_name,
|
||||||
|
Reference in New Issue
Block a user