From 207a2e8627ad371b4d1e7bc4d3a39fe97ef2999c Mon Sep 17 00:00:00 2001
From: Jean-Marc Valin <jmvalin@jmvalin.ca>
Date: Sat, 8 Oct 2011 15:08:38 -0400
Subject: [PATCH] Fixes a rare integer overflow in the SILK "50% of max rate"
 rule

---
 src/opus_encoder.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/opus_encoder.c b/src/opus_encoder.c
index 586091fb5..e9a6c25c5 100644
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -753,7 +753,7 @@ int opus_encode_float(OpusEncoder *st, const opus_val16 *pcm, int frame_size,
             }
         }
         /* SILK is not allow to use more than 50% of max_data_bytes */
-        if (max_data_bytes < 2*st->silk_mode.bitRate*frame_size / (st->Fs * 8))
+        if (max_data_bytes < st->silk_mode.bitRate*frame_size / (st->Fs * 4))
            st->silk_mode.bitRate = max_data_bytes*st->Fs*4/frame_size;
 
         st->silk_mode.payloadSize_ms = 1000 * frame_size / st->Fs;
-- 
GitLab