aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/shorten.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-09-22 17:25:47 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-09-22 17:25:51 +0200
commit44ebb2556d099c8103247b7c2b60eab399f300af (patch)
tree3dc5715fcb8f8b3e145b6fcc55615db3ec3a8322 /libavcodec/shorten.c
parent0a41da3e9d2090c562b752d086bcbd4dee69c796 (diff)
parent5ebb5a32bdd910a8afb316c51ed0b322f5600ae5 (diff)
downloadffmpeg-44ebb2556d099c8103247b7c2b60eab399f300af.tar.gz
Merge commit '5ebb5a32bdd910a8afb316c51ed0b322f5600ae5' into release/0.8
* commit '5ebb5a32bdd910a8afb316c51ed0b322f5600ae5': shorten: report meaningful errors shorten: set invalid channels count to 0 Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/shorten.c')
-rw-r--r--libavcodec/shorten.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c
index e8b4cb9d95..628dd2f385 100644
--- a/libavcodec/shorten.c
+++ b/libavcodec/shorten.c
@@ -119,11 +119,11 @@ static int allocate_buffers(ShortenContext *s)
for (chan=0; chan<s->channels; chan++) {
if(FFMAX(1, s->nmean) >= UINT_MAX/sizeof(int32_t)){
av_log(s->avctx, AV_LOG_ERROR, "nmean too large\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
if(s->blocksize + s->nwrap >= UINT_MAX/sizeof(int32_t) || s->blocksize + s->nwrap <= (unsigned)s->nwrap){
av_log(s->avctx, AV_LOG_ERROR, "s->blocksize + s->nwrap too large\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
tmp_ptr = av_realloc(s->offset[chan], sizeof(int32_t)*FFMAX(1, s->nmean));
@@ -209,14 +209,14 @@ static int decode_wave_header(AVCodecContext *avctx, uint8_t *header, int header
init_get_bits(&hb, header, header_size*8);
if (get_le32(&hb) != MKTAG('R','I','F','F')) {
av_log(avctx, AV_LOG_ERROR, "missing RIFF tag\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
skip_bits_long(&hb, 32); /* chunk_size */
if (get_le32(&hb) != MKTAG('W','A','V','E')) {
av_log(avctx, AV_LOG_ERROR, "missing WAVE tag\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
while (get_le32(&hb) != MKTAG('f','m','t',' ')) {
@@ -227,7 +227,7 @@ static int decode_wave_header(AVCodecContext *avctx, uint8_t *header, int header
if (len < 16) {
av_log(avctx, AV_LOG_ERROR, "fmt chunk was too short\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
wave_format = get_le16(&hb);
@@ -237,7 +237,7 @@ static int decode_wave_header(AVCodecContext *avctx, uint8_t *header, int header
break;
default:
av_log(avctx, AV_LOG_ERROR, "unsupported wave format\n");
- return -1;
+ return AVERROR(ENOSYS);
}
avctx->channels = get_le16(&hb);
@@ -248,7 +248,7 @@ static int decode_wave_header(AVCodecContext *avctx, uint8_t *header, int header
if (avctx->bits_per_coded_sample != 16) {
av_log(avctx, AV_LOG_ERROR, "unsupported number of bits per sample\n");
- return -1;
+ return AVERROR(ENOSYS);
}
len -= 16;
@@ -344,6 +344,7 @@ static int shorten_decode_frame(AVCodecContext *avctx,
s->channels = get_uint(s, CHANSIZE);
if (s->channels <= 0 || s->channels > MAX_CHANNELS) {
av_log(s->avctx, AV_LOG_ERROR, "too many channels: %d\n", s->channels);
+ s->channels = 0;
return -1;
}
@@ -534,7 +535,7 @@ frame_done:
av_log(s->avctx, AV_LOG_ERROR, "overread: %d\n", i - buf_size);
s->bitstream_size=0;
s->bitstream_index=0;
- return -1;
+ return AVERROR_INVALIDDATA;
}
if (s->bitstream_size) {
s->bitstream_index += i;