aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/lzma
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2008-08-31 11:47:01 +0300
committerLasse Collin <lasse.collin@tukaani.org>2008-08-31 11:47:01 +0300
commitede675f9ac1ca82a7d7c290324adba672118bc8d (patch)
treee264ef6546a47d93c70859a9def523ec3b1baa07 /src/liblzma/lzma
parentSort of garbage collection commit. :-| Many things are still (diff)
downloadxz-ede675f9ac1ca82a7d7c290324adba672118bc8d.tar.xz
Fix wrong pointer calculation in LZMA encoder.
Diffstat (limited to 'src/liblzma/lzma')
-rw-r--r--src/liblzma/lzma/lzma_encoder.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/liblzma/lzma/lzma_encoder.c b/src/liblzma/lzma/lzma_encoder.c
index a84801e7..5302a707 100644
--- a/src/liblzma/lzma/lzma_encoder.c
+++ b/src/liblzma/lzma/lzma_encoder.c
@@ -165,8 +165,10 @@ match(lzma_coder *coder, const uint32_t pos_state,
const uint32_t pos_reduced = distance - base;
if (pos_slot < END_POS_MODEL_INDEX) {
+ // Careful here: base - pos_slot - 1 can be -1, but
+ // rc_bittree_reverse starts at probs[1], not probs[0].
rc_bittree_reverse(&coder->rc,
- &coder->pos_special[base - pos_slot - 1],
+ coder->pos_special + base - pos_slot - 1,
footer_bits, pos_reduced);
} else {
rc_direct(&coder->rc, pos_reduced >> ALIGN_BITS,