speex_bits_write now properly inserts a terminator before copying the data
authorjm <jm@0101bb08-14d6-0310-b084-bc0e0c8e3800>
Fri, 22 Aug 2003 21:44:42 +0000 (21:44 +0000)
committerjm <jm@0101bb08-14d6-0310-b084-bc0e0c8e3800>
Fri, 22 Aug 2003 21:44:42 +0000 (21:44 +0000)
git-svn-id: http://svn.xiph.org/trunk/speex@5236 0101bb08-14d6-0310-b084-bc0e0c8e3800

libspeex/bits.c

index 68285e0..b7ba018 100644 (file)
@@ -166,6 +166,17 @@ void speex_bits_read_whole_bytes(SpeexBits *bits, char *bytes, int len)
 int speex_bits_write(SpeexBits *bits, char *bytes, int max_len)
 {
    int i;
+   char bytePtr, bitPtr, nbBits;
+
+   /* Insert terminator, but save the data so we can put it back after */
+   bitPtr=bits->bitPtr;
+   bytePtr=bits->bytePtr;
+   nbBits=bits->nbBits;
+   speex_bits_insert_terminator(bits);
+   bits->bitPtr=bitPtr;
+   bits->bytePtr=bytePtr;
+   bits->nbBits=nbBits;
+   
    if (max_len > ((bits->nbBits+7)>>3))
       max_len = ((bits->nbBits+7)>>3);
    for (i=0;i<max_len;i++)