Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.xiph.org/xiph/opus.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@jmvalin.ca>2012-12-04 23:13:00 +0400
committerJean-Marc Valin <jmvalin@jmvalin.ca>2012-12-05 23:21:17 +0400
commitf56ac441714236bb2699228179c86dfbb2761e99 (patch)
treef4d9290788b00d0d37ad9e7f4143abafd96581d4
parent24f1c51f13ae5a4d66ea0f1911d68930a087e67c (diff)
Don't update the internal decoder state until we know the packet is valid
-rw-r--r--src/opus_decoder.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/opus_decoder.c b/src/opus_decoder.c
index 9729308c..64d1da5d 100644
--- a/src/opus_decoder.c
+++ b/src/opus_decoder.c
@@ -756,17 +756,20 @@ int opus_decode_native(OpusDecoder *st, const unsigned char *data,
return frame_size;
}
tot_offset = 0;
- st->mode = packet_mode;
- st->bandwidth = packet_bandwidth;
- st->frame_size = packet_frame_size;
- st->stream_channels = packet_stream_channels;
if (count < 0)
return count;
tot_offset += offset;
- if (count*st->frame_size > frame_size)
+ if (count*packet_frame_size > frame_size)
return OPUS_BUFFER_TOO_SMALL;
+
+ /* Update the state as the last step to avoid updating it on an invalid packet */
+ st->mode = packet_mode;
+ st->bandwidth = packet_bandwidth;
+ st->frame_size = packet_frame_size;
+ st->stream_channels = packet_stream_channels;
+
nb_samples=0;
for (i=0;i<count;i++)
{