summaryrefslogtreecommitdiff
path: root/codebook.c
diff options
context:
space:
mode:
authorTim Terriberry <tterribe@xiph.org>2010-10-14 01:33:46 +0000
committerTim Terriberry <tterribe@xiph.org>2010-10-14 01:33:46 +0000
commitcffec5374b06db0e3052879234e1350dfaf8c246 (patch)
treee4f4dc9a39db8fcf39f5ab0039b869aed389652d /codebook.c
parent85749ea451123aedeb1ec3bfbbc15e9288917979 (diff)
downloadtremor-cffec5374b06db0e3052879234e1350dfaf8c246.tar.gz
Port r17029 and r17050 from libvorbis.
Fix leak when aborting out of static_codebook unpack. Closes #1663. git-svn-id: https://svn.xiph.org/trunk/Tremor@17530 0101bb08-14d6-0310-b084-bc0e0c8e3800
Diffstat (limited to 'codebook.c')
-rw-r--r--codebook.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/codebook.c b/codebook.c
index 3381f73..95bd34a 100644
--- a/codebook.c
+++ b/codebook.c
@@ -25,9 +25,9 @@
/* unpacks a codebook from the packet buffer into the codebook struct,
readies the codebook auxiliary structures for decode *************/
-int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
+static_codebook *vorbis_staticbook_unpack(oggpack_buffer *opb){
long i,j;
- memset(s,0,sizeof(*s));
+ static_codebook *s=_ogg_calloc(1,sizeof(*s));
/* make sure alignment is correct */
if(oggpack_read(opb,24)!=0x564342)goto _eofout;
@@ -85,7 +85,7 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
break;
default:
/* EOF */
- return(-1);
+ goto _eofout;
}
/* Do we have a mapping to unpack? */
@@ -127,12 +127,12 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
}
/* all set */
- return(0);
+ return(s);
_errout:
_eofout:
- vorbis_staticbook_clear(s);
- return(-1);
+ vorbis_staticbook_destroy(s);
+ return(NULL);
}
/* the 'eliminate the decode tree' optimization actually requires the