Skip to content

Commit b4e00f1

Browse files
bjorn3folkertdev
authored andcommitted
Use 8192 elements for huffman x2 tables in zstd_v07
1 parent e72ecac commit b4e00f1

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/legacy/zstd_v07.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,13 @@ struct HUFv07_DTable {
122122
data: [u32; 4096],
123123
}
124124
impl HUFv07_DTable {
125-
fn as_x2(&self) -> &[HUFv07_DEltX2; 4096] {
125+
fn as_x2(&self) -> &[HUFv07_DEltX2; 8192] {
126+
// This is safe as HUFv07_DEltX2 is only 2 bytes long, not 4 bytes like HUFv07_DEltX4.
126127
unsafe { core::mem::transmute(&self.data) }
127128
}
128129

129-
// Note: Using 8192 as HUFv07_readDTableX2 can write past 4096.
130-
// This is safe as HUFv07_DEltX2 is only 2 bytes long, not 4 bytes like HUFv07_DEltX4.
131130
fn as_x2_mut(&mut self) -> &mut [HUFv07_DEltX2; 8192] {
131+
// This is safe as HUFv07_DEltX2 is only 2 bytes long, not 4 bytes like HUFv07_DEltX4.
132132
unsafe { core::mem::transmute(&mut self.data) }
133133
}
134134

@@ -862,7 +862,7 @@ fn HUFv07_readDTableX2(DTable: &mut HUFv07_DTable, src: &[u8]) -> Result<usize,
862862
}
863863
fn HUFv07_decodeSymbolX2(
864864
Dstream: &mut BITv07_DStream_t,
865-
dt: &[HUFv07_DEltX2; 4096],
865+
dt: &[HUFv07_DEltX2; 8192],
866866
dtLog: u32,
867867
) -> u8 {
868868
let val = Dstream.look_bits_fast(dtLog);
@@ -874,7 +874,7 @@ fn HUFv07_decodeSymbolX2(
874874
fn HUFv07_decodeStreamX2(
875875
mut dst: Writer<'_>,
876876
bitDPtr: &mut BITv07_DStream_t,
877-
dt: &[HUFv07_DEltX2; 4096],
877+
dt: &[HUFv07_DEltX2; 8192],
878878
dtLog: u32,
879879
) -> usize {
880880
let dst_capacity = dst.capacity();

0 commit comments

Comments
 (0)