[xiph-commits] r17510 - trunk/Tremor
tterribe at svn.xiph.org
tterribe at svn.xiph.org
Wed Oct 13 13:04:39 PDT 2010
Author: tterribe
Date: 2010-10-13 13:04:39 -0700 (Wed, 13 Oct 2010)
New Revision: 17510
Modified:
trunk/Tremor/sharedbook.c
Log:
Forward port r14811 and r16073 from libvorbis.
Additional bulletproofing to hufftree decoding; reject underpopulated trees
up-front.
Handle the case of single-entry codebooks.
Modified: trunk/Tremor/sharedbook.c
===================================================================
--- trunk/Tremor/sharedbook.c 2010-10-13 19:29:58 UTC (rev 17509)
+++ trunk/Tremor/sharedbook.c 2010-10-13 20:04:39 UTC (rev 17510)
@@ -121,7 +121,20 @@
}else
if(sparsecount==0)count++;
}
-
+
+ /* sanity check the huffman tree; an underpopulated tree must be
+ rejected. The only exception is the one-node pseudo-nil tree,
+ which appears to be underpopulated because the tree doesn't
+ really exist; there's only one possible 'codeword' or zero bits,
+ but the above tree-gen code doesn't mark that. */
+ if(sparsecount != 1){
+ for(i=1;i<33;i++)
+ if(marker[i] & (0xffffffffUL>>(32-i))){
+ _ogg_free(r);
+ return(NULL);
+ }
+ }
+
/* bitreverse the words because our bitwise packer/unpacker is LSb
endian */
for(i=0,count=0;i<n;i++){
More information about the commits
mailing list