diff options
| author | Nils Wallménius <nils@rockbox.org> | 2010-12-08 16:07:46 +0000 |
|---|---|---|
| committer | Nils Wallménius <nils@rockbox.org> | 2010-12-08 16:07:46 +0000 |
| commit | c0e3e1628575647ec9083fd23c26de85ea8f86c0 (patch) | |
| tree | 8c19a660d381df5c1c8d0468b4fac3f6cb1ff995 /apps/codecs/libtremor/codebook.c | |
| parent | a5897697f9d38b3a7131a504c7251ac5fe2dcb15 (diff) | |
| download | rockbox-c0e3e1628575647ec9083fd23c26de85ea8f86c0.zip rockbox-c0e3e1628575647ec9083fd23c26de85ea8f86c0.tar.gz rockbox-c0e3e1628575647ec9083fd23c26de85ea8f86c0.tar.bz2 rockbox-c0e3e1628575647ec9083fd23c26de85ea8f86c0.tar.xz | |
libtremor: merge upstream revision 17528-17530, more error checking and bug fixes
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28768 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libtremor/codebook.c')
| -rw-r--r-- | apps/codecs/libtremor/codebook.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/apps/codecs/libtremor/codebook.c b/apps/codecs/libtremor/codebook.c index 2b92e21..fd47328 100644 --- a/apps/codecs/libtremor/codebook.c +++ b/apps/codecs/libtremor/codebook.c @@ -26,9 +26,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; @@ -75,17 +75,18 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){ s->lengthlist=(long *)_ogg_malloc(sizeof(*s->lengthlist)*s->entries); for(i=0;i<s->entries;){ - long num=oggpack_read(opb,_ilog(s->entries-i)); - if(num==-1)goto _eofout; - for(j=0;j<num && i<s->entries;j++,i++) - s->lengthlist[i]=length; - length++; + long num=oggpack_read(opb,_ilog(s->entries-i)); + if(num==-1)goto _eofout; + if(length>32)goto _errout; + for(j=0;j<num && i<s->entries;j++,i++) + s->lengthlist[i]=length; + length++; } } break; default: /* EOF */ - return(-1); + goto _eofout; } /* Do we have a mapping to unpack? */ @@ -127,12 +128,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 |