[xiph-commits] r17030 - trunk/vorbis/lib
xiphmont at svn.xiph.org
xiphmont at svn.xiph.org
Wed Mar 24 23:52:55 PDT 2010
Author: xiphmont
Date: 2010-03-24 23:52:55 -0700 (Wed, 24 Mar 2010)
New Revision: 17030
Modified:
trunk/vorbis/lib/codebook.c
trunk/vorbis/lib/codebook.h
trunk/vorbis/lib/info.c
trunk/vorbis/lib/sharedbook.c
Log:
Fix leak when aborting out of static_codebook unpack. Closes #1663.
Modified: trunk/vorbis/lib/codebook.c
===================================================================
--- trunk/vorbis/lib/codebook.c 2010-03-25 05:29:15 UTC (rev 17029)
+++ trunk/vorbis/lib/codebook.c 2010-03-25 06:52:55 UTC (rev 17030)
@@ -146,9 +146,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));
s->allocedp=1;
/* make sure alignment is correct */
@@ -207,7 +207,7 @@
break;
default:
/* EOF */
- return(-1);
+ goto _eofout;
}
/* Do we have a mapping to unpack? */
@@ -249,12 +249,12 @@
}
/* all set */
- return(0);
+ return(s);
_errout:
_eofout:
- vorbis_staticbook_clear(s);
- return(-1);
+ vorbis_staticbook_destroy(s);
+ return(NULL);
}
/* returns the number of bits ************************************************/
Modified: trunk/vorbis/lib/codebook.h
===================================================================
--- trunk/vorbis/lib/codebook.h 2010-03-25 05:29:15 UTC (rev 17029)
+++ trunk/vorbis/lib/codebook.h 2010-03-25 06:52:55 UTC (rev 17030)
@@ -79,7 +79,6 @@
int delta;
} codebook;
-extern void vorbis_staticbook_clear(static_codebook *b);
extern void vorbis_staticbook_destroy(static_codebook *b);
extern int vorbis_book_init_encode(codebook *dest,const static_codebook *source);
extern int vorbis_book_init_decode(codebook *dest,const static_codebook *source);
@@ -100,7 +99,7 @@
extern int vorbis_staticbook_pack(const static_codebook *c,oggpack_buffer *b);
-extern int vorbis_staticbook_unpack(oggpack_buffer *b,static_codebook *c);
+extern static_codebook *vorbis_staticbook_unpack(oggpack_buffer *b);
extern int vorbis_book_encode(codebook *book, int a, oggpack_buffer *b);
Modified: trunk/vorbis/lib/info.c
===================================================================
--- trunk/vorbis/lib/info.c 2010-03-25 05:29:15 UTC (rev 17029)
+++ trunk/vorbis/lib/info.c 2010-03-25 06:52:55 UTC (rev 17030)
@@ -279,7 +279,7 @@
if(ci->books<=0)goto err_out;
for(i=0;i<ci->books;i++){
ci->book_param[i]=_ogg_calloc(1,sizeof(*ci->book_param[i]));
- if(vorbis_staticbook_unpack(opb,ci->book_param[i]))goto err_out;
+ if(!ci->book_param[i])goto err_out;
}
/* time backend settings; hooks are unused */
Modified: trunk/vorbis/lib/sharedbook.c
===================================================================
--- trunk/vorbis/lib/sharedbook.c 2010-03-25 05:29:15 UTC (rev 17029)
+++ trunk/vorbis/lib/sharedbook.c 2010-03-25 06:52:55 UTC (rev 17030)
@@ -258,19 +258,13 @@
return(NULL);
}
-void vorbis_staticbook_clear(static_codebook *b){
+void vorbis_staticbook_destroy(static_codebook *b){
if(b->allocedp){
if(b->quantlist)_ogg_free(b->quantlist);
if(b->lengthlist)_ogg_free(b->lengthlist);
memset(b,0,sizeof(*b));
- }
-}
-
-void vorbis_staticbook_destroy(static_codebook *b){
- if(b->allocedp){
- vorbis_staticbook_clear(b);
_ogg_free(b);
- }
+ } /* otherwise, it is in static memory */
}
void vorbis_book_clear(codebook *b){
More information about the commits
mailing list