shithub: opus

Download patch

ref: 79fa8b6c3b74ca86b2738d3ae7fda4234f3c34cc
parent: 5e171490a98701d982720cc2a03802b4b3dac66b
author: Jean-Marc Valin <[email protected]>
date: Wed Feb 27 19:14:02 EST 2008

Just in case sizeof(char)!=1

--- a/libcelt/entenc.c
+++ b/libcelt/entenc.c
@@ -11,7 +11,7 @@
 #define EC_BUFFER_INCREMENT (256)
 
 void ec_byte_writeinit(ec_byte_buffer *_b){
-  _b->ptr=_b->buf=malloc(EC_BUFFER_INCREMENT);
+  _b->ptr=_b->buf=malloc(EC_BUFFER_INCREMENT*sizeof(char));
   _b->storage=EC_BUFFER_INCREMENT;
 }
 
@@ -23,7 +23,7 @@
   ptrdiff_t endbyte;
   endbyte=_b->ptr-_b->buf;
   if(endbyte>=_b->storage){
-    _b->buf=realloc(_b->buf,_b->storage+EC_BUFFER_INCREMENT);
+    _b->buf=realloc(_b->buf,(_b->storage+EC_BUFFER_INCREMENT)*sizeof(char));
     _b->storage+=EC_BUFFER_INCREMENT;
     _b->ptr=_b->buf+endbyte;
   }
@@ -34,7 +34,7 @@
   ptrdiff_t endbyte;
   endbyte=_b->ptr-_b->buf;
   if(endbyte+4>_b->storage){
-    _b->buf=realloc(_b->buf,_b->storage+EC_BUFFER_INCREMENT);
+    _b->buf=realloc(_b->buf,(_b->storage+EC_BUFFER_INCREMENT)*sizeof(char));
     _b->storage+=EC_BUFFER_INCREMENT;
     _b->ptr=_b->buf+endbyte;
   }
@@ -52,7 +52,7 @@
   endbyte=_b->ptr-_b->buf;
   if(endbyte+_bytes>_b->storage){
     _b->storage=endbyte+_bytes+EC_BUFFER_INCREMENT;
-    _b->buf=realloc(_b->buf,_b->storage);
+    _b->buf=realloc(_b->buf,_b->storage*sizeof(char));
     _b->ptr=_b->buf+endbyte;
   }
   memmove(_b->ptr,_source,_bytes);