Commit bd17a40a authored by Ronald S. Bultje's avatar Ronald S. Bultje

lcl: return negative error codes on decode_init() errors.

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
parent 984b914c
...@@ -481,7 +481,7 @@ static av_cold int decode_init(AVCodecContext *avctx) ...@@ -481,7 +481,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
if (avctx->extradata_size < 8) { if (avctx->extradata_size < 8) {
av_log(avctx, AV_LOG_ERROR, "Extradata size too small.\n"); av_log(avctx, AV_LOG_ERROR, "Extradata size too small.\n");
return 1; return AVERROR_INVALIDDATA;
} }
/* Check codec type */ /* Check codec type */
...@@ -530,7 +530,7 @@ static av_cold int decode_init(AVCodecContext *avctx) ...@@ -530,7 +530,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
break; break;
default: default:
av_log(avctx, AV_LOG_ERROR, "Unsupported image format %d.\n", c->imgtype); av_log(avctx, AV_LOG_ERROR, "Unsupported image format %d.\n", c->imgtype);
return 1; return AVERROR_INVALIDDATA;
} }
/* Detect compression method */ /* Detect compression method */
...@@ -547,7 +547,7 @@ static av_cold int decode_init(AVCodecContext *avctx) ...@@ -547,7 +547,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
break; break;
default: default:
av_log(avctx, AV_LOG_ERROR, "Unsupported compression format for MSZH (%d).\n", c->compression); av_log(avctx, AV_LOG_ERROR, "Unsupported compression format for MSZH (%d).\n", c->compression);
return 1; return AVERROR_INVALIDDATA;
} }
break; break;
#if CONFIG_ZLIB_DECODER #if CONFIG_ZLIB_DECODER
...@@ -565,7 +565,7 @@ static av_cold int decode_init(AVCodecContext *avctx) ...@@ -565,7 +565,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
default: default:
if (c->compression < Z_NO_COMPRESSION || c->compression > Z_BEST_COMPRESSION) { if (c->compression < Z_NO_COMPRESSION || c->compression > Z_BEST_COMPRESSION) {
av_log(avctx, AV_LOG_ERROR, "Unsupported compression level for ZLIB: (%d).\n", c->compression); av_log(avctx, AV_LOG_ERROR, "Unsupported compression level for ZLIB: (%d).\n", c->compression);
return 1; return AVERROR_INVALIDDATA;
} }
av_log(avctx, AV_LOG_DEBUG, "Compression level for ZLIB: (%d).\n", c->compression); av_log(avctx, AV_LOG_DEBUG, "Compression level for ZLIB: (%d).\n", c->compression);
} }
...@@ -573,14 +573,14 @@ static av_cold int decode_init(AVCodecContext *avctx) ...@@ -573,14 +573,14 @@ static av_cold int decode_init(AVCodecContext *avctx)
#endif #endif
default: default:
av_log(avctx, AV_LOG_ERROR, "BUG! Unknown codec in compression switch.\n"); av_log(avctx, AV_LOG_ERROR, "BUG! Unknown codec in compression switch.\n");
return 1; return AVERROR_INVALIDDATA;
} }
/* Allocate decompression buffer */ /* Allocate decompression buffer */
if (c->decomp_size) { if (c->decomp_size) {
if ((c->decomp_buf = av_malloc(max_decomp_size)) == NULL) { if ((c->decomp_buf = av_malloc(max_decomp_size)) == NULL) {
av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n"); av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n");
return 1; return AVERROR(ENOMEM);
} }
} }
...@@ -606,7 +606,7 @@ static av_cold int decode_init(AVCodecContext *avctx) ...@@ -606,7 +606,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
if (zret != Z_OK) { if (zret != Z_OK) {
av_log(avctx, AV_LOG_ERROR, "Inflate init error: %d\n", zret); av_log(avctx, AV_LOG_ERROR, "Inflate init error: %d\n", zret);
av_freep(&c->decomp_buf); av_freep(&c->decomp_buf);
return 1; return AVERROR_UNKNOWN;
} }
} }
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment