From 06de049737d2bc45ee439f38fb5e214ac54e38bb Mon Sep 17 00:00:00 2001 From: Michihiro NAKAJIMA Date: Fri, 17 Feb 2012 11:21:24 +0900 Subject: [PATCH] Issue 243: CAB decompression doesn't work when libarchive build with MSVC2010. Prevent unexpected code optimization from MSVC /O2 option. It made CAB reader fail to decompress LZX. --- libarchive/archive_read_support_format_cab.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libarchive/archive_read_support_format_cab.c b/libarchive/archive_read_support_format_cab.c index b634ed394..0bc7c999c 100644 --- a/libarchive/archive_read_support_format_cab.c +++ b/libarchive/archive_read_support_format_cab.c @@ -2068,6 +2068,7 @@ lzx_decode_init(struct lzx_stream *strm, int w_bits) struct lzx_dec *ds; int slot, w_size, w_slot; int base, footer; + int base_inc[18]; if (strm->ds == NULL) { strm->ds = calloc(1, sizeof(*strm->ds)); @@ -2102,13 +2103,15 @@ lzx_decode_init(struct lzx_stream *strm, int w_bits) lzx_huffman_free(&(ds->mt)); } + for (footer = 0; footer < 18; footer++) + base_inc[footer] = 1 << footer; base = footer = 0; for (slot = 0; slot < w_slot; slot++) { int n; if (footer == 0) base = slot; else - base += 1 << footer; + base += base_inc[footer]; if (footer < 17) { footer = -2; for (n = base; n; n >>= 1) -- 2.47.3