avcodec/mxpegdec: Fix memleaks upon init failure
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
(cherry picked from commit 9de6688cc4
)
This commit is contained in:
@ -2803,6 +2803,8 @@ the_end_no_picture:
|
|||||||
return buf_ptr - buf;
|
return buf_ptr - buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* mxpeg may call the following function (with a blank MJpegDecodeContext)
|
||||||
|
* even without having called ff_mjpeg_decode_init(). */
|
||||||
av_cold int ff_mjpeg_decode_end(AVCodecContext *avctx)
|
av_cold int ff_mjpeg_decode_end(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
MJpegDecodeContext *s = avctx->priv_data;
|
MJpegDecodeContext *s = avctx->priv_data;
|
||||||
|
@ -67,10 +67,8 @@ static av_cold int mxpeg_decode_init(AVCodecContext *avctx)
|
|||||||
|
|
||||||
s->picture[0] = av_frame_alloc();
|
s->picture[0] = av_frame_alloc();
|
||||||
s->picture[1] = av_frame_alloc();
|
s->picture[1] = av_frame_alloc();
|
||||||
if (!s->picture[0] || !s->picture[1]) {
|
if (!s->picture[0] || !s->picture[1])
|
||||||
mxpeg_decode_end(avctx);
|
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
}
|
|
||||||
|
|
||||||
s->jpg.picture_ptr = s->picture[0];
|
s->jpg.picture_ptr = s->picture[0];
|
||||||
return ff_mjpeg_decode_init(avctx);
|
return ff_mjpeg_decode_init(avctx);
|
||||||
@ -352,5 +350,5 @@ AVCodec ff_mxpeg_decoder = {
|
|||||||
.decode = mxpeg_decode_frame,
|
.decode = mxpeg_decode_frame,
|
||||||
.capabilities = AV_CODEC_CAP_DR1,
|
.capabilities = AV_CODEC_CAP_DR1,
|
||||||
.max_lowres = 3,
|
.max_lowres = 3,
|
||||||
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
|
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user