]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Issue 243: CAB decompression doesn't work when libarchive build with MSVC2010.
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Fri, 17 Feb 2012 02:21:24 +0000 (11:21 +0900)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Sat, 18 Feb 2012 07:00:51 +0000 (16:00 +0900)
Prevent unexpected code optimization from MSVC /O2 option.
It made CAB reader fail to decompress LZX.

libarchive/archive_read_support_format_cab.c

index b634ed394f35e8ed5b289f19790cd8bfa488fcea..0bc7c999cbaf15699f3081f1bbc61a34b234a190 100644 (file)
@@ -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)