diff options
author | Himangi Saraogi <himangi774@gmail.com> | 2015-04-01 21:35:16 +0530 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-04-01 19:33:45 +0200 |
commit | 5b02e84bdb15e97fda0fcbe592a98a98bbd0034a (patch) | |
tree | 2199b4ac802770b37ca416bb67772f5e432b6166 /libavcodec/smvjpegdec.c | |
parent | b9fbd034bfd4b323d57bc2ac888301c93fcfd4ca (diff) | |
download | ffmpeg-5b02e84bdb15e97fda0fcbe592a98a98bbd0034a.tar.gz |
lavc/smvjpegdec: Avoid null dereference and return meaningful error codes
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/smvjpegdec.c')
-rw-r--r-- | libavcodec/smvjpegdec.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/libavcodec/smvjpegdec.c b/libavcodec/smvjpegdec.c index 5eca9bb6a2..f30d240e2c 100644 --- a/libavcodec/smvjpegdec.c +++ b/libavcodec/smvjpegdec.c @@ -94,7 +94,7 @@ static av_cold int smvjpeg_decode_init(AVCodecContext *avctx) SMVJpegDecodeContext *s = avctx->priv_data; AVCodec *codec; AVDictionary *thread_opt = NULL; - int ret = 0; + int ret = 0, r; s->frames_per_jpeg = 0; @@ -115,13 +115,14 @@ static av_cold int smvjpeg_decode_init(AVCodecContext *avctx) if (s->frames_per_jpeg <= 0) { av_log(avctx, AV_LOG_ERROR, "Invalid number of frames per jpeg.\n"); - ret = -1; + ret = AVERROR_INVALIDDATA; } codec = avcodec_find_decoder(AV_CODEC_ID_MJPEG); if (!codec) { av_log(avctx, AV_LOG_ERROR, "MJPEG codec not found\n"); - ret = -1; + smvjpeg_decode_end(avctx); + return AVERROR_DECODER_NOT_FOUND; } s->avctx = avcodec_alloc_context3(codec); @@ -130,9 +131,9 @@ static av_cold int smvjpeg_decode_init(AVCodecContext *avctx) s->avctx->refcounted_frames = 1; s->avctx->flags = avctx->flags; s->avctx->idct_algo = avctx->idct_algo; - if (ff_codec_open2_recursive(s->avctx, codec, &thread_opt) < 0) { + if ((r = ff_codec_open2_recursive(s->avctx, codec, &thread_opt)) < 0) { av_log(avctx, AV_LOG_ERROR, "MJPEG codec failed to open\n"); - ret = -1; + ret = r; } av_dict_free(&thread_opt); |