You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
lavc/smvjpegdec: Avoid null dereference and return meaningful error codes
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
committed by
Michael Niedermayer
parent
b9fbd034bf
commit
5b02e84bdb
@@ -94,7 +94,7 @@ static av_cold int smvjpeg_decode_init(AVCodecContext *avctx)
|
|||||||
SMVJpegDecodeContext *s = avctx->priv_data;
|
SMVJpegDecodeContext *s = avctx->priv_data;
|
||||||
AVCodec *codec;
|
AVCodec *codec;
|
||||||
AVDictionary *thread_opt = NULL;
|
AVDictionary *thread_opt = NULL;
|
||||||
int ret = 0;
|
int ret = 0, r;
|
||||||
|
|
||||||
s->frames_per_jpeg = 0;
|
s->frames_per_jpeg = 0;
|
||||||
|
|
||||||
@@ -115,13 +115,14 @@ static av_cold int smvjpeg_decode_init(AVCodecContext *avctx)
|
|||||||
|
|
||||||
if (s->frames_per_jpeg <= 0) {
|
if (s->frames_per_jpeg <= 0) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Invalid number of frames per jpeg.\n");
|
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);
|
codec = avcodec_find_decoder(AV_CODEC_ID_MJPEG);
|
||||||
if (!codec) {
|
if (!codec) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "MJPEG codec not found\n");
|
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);
|
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->refcounted_frames = 1;
|
||||||
s->avctx->flags = avctx->flags;
|
s->avctx->flags = avctx->flags;
|
||||||
s->avctx->idct_algo = avctx->idct_algo;
|
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");
|
av_log(avctx, AV_LOG_ERROR, "MJPEG codec failed to open\n");
|
||||||
ret = -1;
|
ret = r;
|
||||||
}
|
}
|
||||||
av_dict_free(&thread_opt);
|
av_dict_free(&thread_opt);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user