Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 151252
Collapse All | Expand All

(-)src/huf.c (-6 / +6 lines)
Lines 338-344 Link Here
338
    }
338
    }
339
    else {
339
    else {
340
        i = 0;
340
        i = 0;
341
        while (i < n) {
341
        while (i < MIN(n, NPT)) {
342
            c = peekbits(3);
342
            c = peekbits(3);
343
            if (c != 7)
343
            if (c != 7)
344
                fillbuf(3);
344
                fillbuf(3);
Lines 354-360 Link Here
354
            pt_len[i++] = c;
354
            pt_len[i++] = c;
355
            if (i == i_special) {
355
            if (i == i_special) {
356
                c = getbits(2);
356
                c = getbits(2);
357
                while (--c >= 0)
357
                while (--c >= 0 && i < NPT)
358
                    pt_len[i++] = 0;
358
                    pt_len[i++] = 0;
359
            }
359
            }
360
        }
360
        }
Lines 379-385 Link Here
379
            c_table[i] = c;
379
            c_table[i] = c;
380
    } else {
380
    } else {
381
        i = 0;
381
        i = 0;
382
        while (i < n) {
382
        while (i < MIN(n,NC)) {
383
            c = pt_table[peekbits(8)];
383
            c = pt_table[peekbits(8)];
384
            if (c >= NT) {
384
            if (c >= NT) {
385
                unsigned short  mask = 1 << (16 - 9);
385
                unsigned short  mask = 1 << (16 - 9);
Lines 389-395 Link Here
389
                    else
389
                    else
390
                        c = left[c];
390
                        c = left[c];
391
                    mask >>= 1;
391
                    mask >>= 1;
392
                } while (c >= NT);
392
                } while (c >= NT && (mask || c != left[c]));
393
            }
393
            }
394
            fillbuf(pt_len[c]);
394
            fillbuf(pt_len[c]);
395
            if (c <= 2) {
395
            if (c <= 2) {
Lines 437-443 Link Here
437
            else
437
            else
438
                j = left[j];
438
                j = left[j];
439
            mask >>= 1;
439
            mask >>= 1;
440
        } while (j >= NC);
440
        } while (j >= NC && (mask || j != left[j]));
441
        fillbuf(c_len[j] - 12);
441
        fillbuf(c_len[j] - 12);
442
    }
442
    }
443
    return j;
443
    return j;
Lines 462-468 Link Here
462
            else
462
            else
463
                j = left[j];
463
                j = left[j];
464
            mask >>= 1;
464
            mask >>= 1;
465
        } while (j >= np);
465
        } while (j >= np && (mask || j != left[j]));
466
        fillbuf(pt_len[j] - 8);
466
        fillbuf(pt_len[j] - 8);
467
    }
467
    }
468
    if (j != 0)
468
    if (j != 0)
(-)src/lha_macro.h (+2 lines)
Lines 194-199 Link Here
194
/* Individual macro define                                                  */
194
/* Individual macro define                                                  */
195
/* ------------------------------------------------------------------------ */
195
/* ------------------------------------------------------------------------ */
196
196
197
#define MIN(a,b) ((a) <= (b) ? (a) : (b))
198
197
/* bitio.c */
199
/* bitio.c */
198
#define peekbits(n)     (bitbuf >> (sizeof(bitbuf)*8 - (n)))
200
#define peekbits(n)     (bitbuf >> (sizeof(bitbuf)*8 - (n)))
199
201
(-)src/maketbl.c (-5 / +19 lines)
Lines 32-39 Link Here
32
    }
32
    }
33
33
34
    /* count */
34
    /* count */
35
    for (i = 0; i < nchar; i++)
35
    for (i = 0; i < nchar; i++) {
36
        count[bitlen[i]]++;
36
        if (bitlen[i] > 16) {
37
            error("Bad table (case a)");
38
            exit(1);
39
        }
40
        else
41
            count[bitlen[i]]++;
42
    }
37
43
38
    /* calculate first code */
44
    /* calculate first code */
39
    total = 0;
45
    total = 0;
Lines 41-48 Link Here
41
        start[i] = total;
47
        start[i] = total;
42
        total += weight[i] * count[i];
48
        total += weight[i] * count[i];
43
    }
49
    }
44
    if ((total & 0xffff) != 0)
50
    if ((total & 0xffff) != 0 || tablebits > 16) { /* 16 for weight below */
45
        error("make_table(): Bad table (5)");
51
        error("make_table(): Bad table (5)");
52
        exit(1);
53
    }
46
54
47
    /* shift data for make table. */
55
    /* shift data for make table. */
48
    m = 16 - tablebits;
56
    m = 16 - tablebits;
Lines 53-59 Link Here
53
61
54
    /* initialize */
62
    /* initialize */
55
    j = start[tablebits + 1] >> m;
63
    j = start[tablebits + 1] >> m;
56
    k = 1 << tablebits;
64
    k = MIN(1 << tablebits, 4096);
57
    if (j != 0)
65
    if (j != 0)
58
        for (i = j; i < k; i++)
66
        for (i = j; i < k; i++)
59
            table[i] = 0;
67
            table[i] = 0;
Lines 66-77 Link Here
66
        l = start[k] + weight[k];
74
        l = start[k] + weight[k];
67
        if (k <= tablebits) {
75
        if (k <= tablebits) {
68
            /* code in table */
76
            /* code in table */
77
            l = MIN(l, 4096);
69
            for (i = start[k]; i < l; i++)
78
            for (i = start[k]; i < l; i++)
70
                table[i] = j;
79
                table[i] = j;
71
        }
80
        }
72
        else {
81
        else {
73
            /* code not in table */
82
            /* code not in table */
74
            p = &table[(i = start[k]) >> m];
83
            i = start[k];
84
            if ((i >> m) > 4096) {
85
                error("Bad table");
86
                exit(1);
87
            }
88
            p = &table[i >> m];
75
            i <<= tablebits;
89
            i <<= tablebits;
76
            n = k - tablebits;
90
            n = k - tablebits;
77
            /* make tree (n length) */
91
            /* make tree (n length) */

Return to bug 151252