# HG changeset patch # User bellard # Date 1041893262 0 # Node ID 6e6773512288b50f587ad95adbf2536b6d857439 # Parent 1936a177d48246c51ce68cc428d71ea8c95a4ec9 oops : better error resilience - should fix most wma decoding problems diff -r 1936a177d482 -r 6e6773512288 wmadec.c --- a/wmadec.c Mon Jan 06 18:09:27 2003 +0000 +++ b/wmadec.c Mon Jan 06 22:47:42 2003 +0000 @@ -1240,7 +1240,7 @@ /* add bit_offset bits to last frame */ if ((s->last_superframe_len + ((bit_offset + 7) >> 3)) > MAX_CODED_SUPERFRAME_SIZE) - return -1; + goto fail; q = s->last_superframe + s->last_superframe_len; len = bit_offset; while (len > 0) { @@ -1259,7 +1259,7 @@ /* this frame is stored in the last superframe and in the current one */ if (wma_decode_frame(s, samples) < 0) - return -1; + goto fail; samples += s->nb_channels * s->frame_len; } @@ -1273,7 +1273,7 @@ s->reset_block_lengths = 1; for(i=0;inb_channels * s->frame_len; } @@ -1283,18 +1283,22 @@ pos >>= 3; len = buf_size - pos; if (len > MAX_CODED_SUPERFRAME_SIZE || len < 0) { - return -1; + goto fail; } s->last_superframe_len = len; memcpy(s->last_superframe, buf + pos, len); } else { /* single frame decode */ if (wma_decode_frame(s, samples) < 0) - return -1; + goto fail; samples += s->nb_channels * s->frame_len; } *data_size = (int8_t *)samples - (int8_t *)data; return s->block_align; + fail: + /* when error, we reset the bit reservoir */ + s->last_superframe_len = 0; + return -1; } static int wma_decode_end(AVCodecContext *avctx)