summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei Jia <wjia@google.com>2015-08-12 10:08:41 -0700
committerWolfgang Wiedmeyer <wolfgit@wiedmeyer.de>2015-10-19 01:29:46 +0200
commit7bf55c9cb03af91c92071c07e4206936b04b397c (patch)
tree89d07f620eb88db6e04a063cf869dc7bac793cac
parent06aa44e37fc2be4320bbbcd3c7cd76c94d277bff (diff)
downloadframeworks_av-7bf55c9cb03af91c92071c07e4206936b04b397c.zip
frameworks_av-7bf55c9cb03af91c92071c07e4206936b04b397c.tar.gz
frameworks_av-7bf55c9cb03af91c92071c07e4206936b04b397c.tar.bz2
libstagefright: fix possible overflow in amrwbenc.
Bug: 23142203 Change-Id: I309df51e4df6412655f04cc093d792bf6c7944f7 (cherry picked from commit 9dd01777aa14bbb90a6cdccf97383bb4e3d717a5) Tested-by: Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de>
-rw-r--r--media/libstagefright/codecs/amrwbenc/src/util.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/media/libstagefright/codecs/amrwbenc/src/util.c b/media/libstagefright/codecs/amrwbenc/src/util.c
index 76ab1b1..333140d 100644
--- a/media/libstagefright/codecs/amrwbenc/src/util.c
+++ b/media/libstagefright/codecs/amrwbenc/src/util.c
@@ -35,9 +35,10 @@ void Set_zero(
)
{
Word32 num = (Word32)L;
- do{
+ while (num > 0) {
*x++ = 0;
- }while(--num !=0);
+ --num;
+ }
}
@@ -54,20 +55,22 @@ void Copy(
)
{
Word32 temp1,temp2,num;
+ if (L <= 0) {
+ return;
+ }
if(L&1)
{
temp1 = *x++;
*y++ = temp1;
}
num = (Word32)(L>>1);
- temp1 = *x++;
- temp2 = *x++;
- do{
- *y++ = temp1;
- *y++ = temp2;
+ while (num > 0) {
temp1 = *x++;
temp2 = *x++;
- }while(--num!=0);
+ *y++ = temp1;
+ *y++ = temp2;
+ --num;
+ }
}