Guard against pathologically small buffer
authorVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Tue, 22 Nov 2011 15:12:44 +0000 (15:12 +0000)
committerJean-Marc Valin <jmvalin@jmvalin.ca>
Tue, 6 Mar 2012 00:59:17 +0000 (19:59 -0500)
src/opus_encoder.c

index 5dda665..c00bc2f 100644 (file)
@@ -1212,6 +1212,11 @@ int opus_encode_float(OpusEncoder *st, const opus_val16 *pcm, int frame_size,
        the decoder to call the PLC */
     if (ec_tell(&enc) > (max_data_bytes-1)*8)
     {
+       if (max_data_bytes < 2)
+       {
+          RESTORE_STACK;
+          return OPUS_BUFFER_TOO_SMALL;
+       }
        data[1] = 0;
        ret = 1;
        st->rangeFinal = 0;