shithub: opus

Download patch

ref: 71877da4eb11d5b6255eacd20c99446820446df0
parent: a7d31b7b15caeeccd1b747c569759a3a7e3d1d1b
author: Jean-Marc Valin <[email protected]>
date: Mon Mar 14 02:45:17 EDT 2011

Error handling

--- a/src/opus_decoder.c
+++ b/src/opus_decoder.c
@@ -149,7 +149,7 @@
     if (audiosize > frame_size)
     {
         fprintf(stderr, "PCM buffer too small: %d vs %d (mode = %d)\n", audiosize, frame_size, mode);
-        return -1;
+        return OPUS_BAD_ARG;
     } else {
         frame_size = audiosize;
     }
@@ -315,7 +315,7 @@
 
 }
 
-int parse_size(const unsigned char *data, int len, short *size)
+static int parse_size(const unsigned char *data, int len, short *size)
 {
 	if (len<1)
 	{
@@ -411,7 +411,8 @@
 		}
 		break;
 	}
-	/* FIXME: Check if the number of samples fits in the output buffer */
+	if (count*st->frame_size > frame_size)
+		return OPUS_BAD_ARG;
 	nb_samples=0;
 	for (i=0;i<count;i++)
 	{