aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2017-11-01 14:13:04 -0300
committerJames Almer <jamrial@gmail.com>2017-11-01 14:13:04 -0300
commitbc98788dd262aacf017fb27d3e1de03f9009839f (patch)
tree0d4a80e0719a5cbf583cdbc18200f0686219b19c
parenta33a15751e274bf9c52a80602531fa3b9c90a9d1 (diff)
parent5edded9df31bc4712a023f89941b4c278f1bd6f5 (diff)
downloadffmpeg-bc98788dd262aacf017fb27d3e1de03f9009839f.tar.gz
Merge commit '5edded9df31bc4712a023f89941b4c278f1bd6f5'
* commit '5edded9df31bc4712a023f89941b4c278f1bd6f5': smacker: Improve error handling See c1947015b2eec65c7fbd702e1d8c22248be511e8 Merged-by: James Almer <jamrial@gmail.com>
-rw-r--r--libavcodec/smacker.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c
index 3a7067e7d5..dad899c791 100644
--- a/libavcodec/smacker.c
+++ b/libavcodec/smacker.c
@@ -279,8 +279,9 @@ static int smacker_decode_header_tree(SmackVContext *smk, GetBitContext *gb, int
goto error;
}
- if (smacker_decode_bigtree(gb, &huff, &ctx, 0) < 0)
- err = -1;
+ res = smacker_decode_bigtree(gb, &huff, &ctx, 0);
+ if (res < 0)
+ err = res;
skip_bits1(gb);
if(ctx.last[0] == -1) ctx.last[0] = huff.current++;
if(ctx.last[1] == -1) ctx.last[1] = huff.current++;
@@ -600,7 +601,7 @@ static av_cold int smka_decode_init(AVCodecContext *avctx)
{
if (avctx->channels < 1 || avctx->channels > 2) {
av_log(avctx, AV_LOG_ERROR, "invalid number of channels\n");
- return AVERROR(EINVAL);
+ return AVERROR_INVALIDDATA;
}
avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
avctx->sample_fmt = avctx->bits_per_coded_sample == 8 ? AV_SAMPLE_FMT_U8 : AV_SAMPLE_FMT_S16;
@@ -630,7 +631,7 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data,
if (buf_size <= 4) {
av_log(avctx, AV_LOG_ERROR, "packet is too small\n");
- return AVERROR(EINVAL);
+ return AVERROR_INVALIDDATA;
}
unp_size = AV_RL32(buf);
@@ -652,11 +653,11 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data,
bits = get_bits1(&gb);
if (stereo ^ (avctx->channels != 1)) {
av_log(avctx, AV_LOG_ERROR, "channels mismatch\n");
- return AVERROR(EINVAL);
+ return AVERROR_INVALIDDATA;
}
if (bits == (avctx->sample_fmt == AV_SAMPLE_FMT_U8)) {
av_log(avctx, AV_LOG_ERROR, "sample format mismatch\n");
- return AVERROR(EINVAL);
+ return AVERROR_INVALIDDATA;
}
/* get output buffer */
@@ -664,7 +665,7 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data,
if (unp_size % (avctx->channels * (bits + 1))) {
av_log(avctx, AV_LOG_ERROR,
"The buffer does not contain an integer number of samples\n");
- return AVERROR(EINVAL);
+ return AVERROR_INVALIDDATA;
}
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;