summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@jmvalin.ca>2018-03-23 14:29:11 -0400
committerJean-Marc Valin <jmvalin@jmvalin.ca>2018-03-27 15:13:26 -0400
commit3995a0c150511572280170280a348fab575edbe7 (patch)
treeaf279be0813dc8a8d852a4cb3b3e507f35e323e4
parenta29504cca7ba43d63dee26e7b0875f314364c9dd (diff)
downloadopus-3995a0c150511572280170280a348fab575edbe7.tar.gz
Adding multistream decoder validation
-rw-r--r--src/opus_multistream_decoder.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/opus_multistream_decoder.c b/src/opus_multistream_decoder.c
index d5dbf4fe..39699fd0 100644
--- a/src/opus_multistream_decoder.c
+++ b/src/opus_multistream_decoder.c
@@ -39,6 +39,21 @@
/* DECODER */
+#if defined(ENABLE_HARDENING) || defined(ENABLE_ASSERTIONS)
+static void validate_ms_decoder(OpusMSDecoder *st)
+{
+ validate_layout(&st->layout);
+#ifdef OPUS_ARCHMASK
+ celt_assert(st->arch >= 0);
+ celt_assert(st->arch <= OPUS_ARCHMASK);
+#endif
+}
+#define VALIDATE_MS_DECODER(st) validate_ms_decoder(st)
+#else
+#define VALIDATE_MS_DECODER(st)
+#endif
+
+
opus_int32 opus_multistream_decoder_get_size(int nb_streams, int nb_coupled_streams)
{
int coupled_size;
@@ -185,6 +200,7 @@ int opus_multistream_decode_native(
VARDECL(opus_val16, buf);
ALLOC_STACK;
+ VALIDATE_MS_DECODER(st);
/* Limit frame_size to avoid excessive stack allocations. */
opus_multistream_decoder_ctl(st, OPUS_GET_SAMPLE_RATE(&Fs));
frame_size = IMIN(frame_size, Fs/25*3);