shithub: libopusenc

Download patch

ref: f12978b9b14c1797891a511b6d5486eebca9c2d4
parent: 6ffb25b255e9533860e0e437d00839a256f12e02
author: Jean-Marc Valin <jmvalin@jmvalin.ca>
date: Mon Feb 5 22:46:26 EST 2018

properly check for incorrect/unsupported mapping family

--- a/src/opusenc.c
+++ b/src/opusenc.c
@@ -297,7 +297,10 @@
   OggOpusEnc *enc=NULL;
   int ret;
   if (family != 0 && family != 1 && family != 255 && family != -1) {
-    if (error) *error = OPE_UNIMPLEMENTED;
+    if (error) {
+      if (family < -1 || family > 255) *error = OPE_BAD_ARG;
+      else *error = OPE_UNIMPLEMENTED;
+    }
     return NULL;
   }
   if (channels <= 0 || channels > 255) {
@@ -396,7 +399,9 @@
   if (enc->st!=NULL) {
     return OPE_TOO_LATE;
   }
-  if (streams <= 0 || streams>255 || coupled_streams<0 || coupled_streams >= 128 || streams+coupled_streams > 255) return OPE_BAD_ARG;
+  if (family < 0 || family > 255) return OPE_BAD_ARG;
+  else if (family != 0 && family != 1 && family != 255) return OPE_UNIMPLEMENTED;
+  else if (streams <= 0 || streams>255 || coupled_streams<0 || coupled_streams >= 128 || streams+coupled_streams > 255) return OPE_BAD_ARG;
   st=opus_multistream_encoder_create(48000, enc->channels, streams, coupled_streams, mapping, OPUS_APPLICATION_AUDIO, &ret);
   if (! (ret == OPUS_OK && st != NULL) ) {
     goto fail;