Branch Coverage

decompress.c
Criterion Covered Total %
branch 363 502 72.3


line true false branch
31 7424 29 for (i = 0; i < 256; i++)
32 1400 6024 if (s->inUse[i]) {
140 29 51093 if (s->state == BZ_X_MAGIC_1) {
198 29 29 GET_UCHAR(BZ_X_MAGIC_1, uc);
0 29 GET_UCHAR(BZ_X_MAGIC_1, uc);
0 29 GET_UCHAR(BZ_X_MAGIC_1, uc);
199 0 29 if (uc != BZ_HDR_B) RETURN(BZ_DATA_ERROR_MAGIC);
201 29 39 GET_UCHAR(BZ_X_MAGIC_2, uc);
10 29 GET_UCHAR(BZ_X_MAGIC_2, uc);
0 29 GET_UCHAR(BZ_X_MAGIC_2, uc);
202 0 29 if (uc != BZ_HDR_Z) RETURN(BZ_DATA_ERROR_MAGIC);
204 29 41 GET_UCHAR(BZ_X_MAGIC_3, uc)
12 29 GET_UCHAR(BZ_X_MAGIC_3, uc)
0 29 GET_UCHAR(BZ_X_MAGIC_3, uc)
205 0 29 if (uc != BZ_HDR_h) RETURN(BZ_DATA_ERROR_MAGIC);
207 29 39 GET_BITS(BZ_X_MAGIC_4, s->blockSize100k, 8)
10 29 GET_BITS(BZ_X_MAGIC_4, s->blockSize100k, 8)
0 29 GET_BITS(BZ_X_MAGIC_4, s->blockSize100k, 8)
208 29 0 if (s->blockSize100k < (BZ_HDR_0 + 1) ||
0 29 if (s->blockSize100k < (BZ_HDR_0 + 1) ||
212 0 29 if (s->smallDecompress) {
217 0 0 if (s->ll16 == NULL || s->ll4 == NULL) RETURN(BZ_MEM_ERROR);
0 0 if (s->ll16 == NULL || s->ll4 == NULL) RETURN(BZ_MEM_ERROR);
220 0 29 if (s->tt == NULL) RETURN(BZ_MEM_ERROR);
223 58 78 GET_UCHAR(BZ_X_BLKHDR_1, uc);
20 58 GET_UCHAR(BZ_X_BLKHDR_1, uc);
0 58 GET_UCHAR(BZ_X_BLKHDR_1, uc);
225 29 29 if (uc == 0x17) goto endhdr_2;
226 0 29 if (uc != 0x31) RETURN(BZ_DATA_ERROR);
227 29 39 GET_UCHAR(BZ_X_BLKHDR_2, uc);
10 29 GET_UCHAR(BZ_X_BLKHDR_2, uc);
0 29 GET_UCHAR(BZ_X_BLKHDR_2, uc);
228 0 29 if (uc != 0x41) RETURN(BZ_DATA_ERROR);
229 29 39 GET_UCHAR(BZ_X_BLKHDR_3, uc);
10 29 GET_UCHAR(BZ_X_BLKHDR_3, uc);
0 29 GET_UCHAR(BZ_X_BLKHDR_3, uc);
230 0 29 if (uc != 0x59) RETURN(BZ_DATA_ERROR);
231 29 39 GET_UCHAR(BZ_X_BLKHDR_4, uc);
10 29 GET_UCHAR(BZ_X_BLKHDR_4, uc);
0 29 GET_UCHAR(BZ_X_BLKHDR_4, uc);
232 0 29 if (uc != 0x26) RETURN(BZ_DATA_ERROR);
233 29 39 GET_UCHAR(BZ_X_BLKHDR_5, uc);
10 29 GET_UCHAR(BZ_X_BLKHDR_5, uc);
0 29 GET_UCHAR(BZ_X_BLKHDR_5, uc);
234 0 29 if (uc != 0x53) RETURN(BZ_DATA_ERROR);
235 29 39 GET_UCHAR(BZ_X_BLKHDR_6, uc);
10 29 GET_UCHAR(BZ_X_BLKHDR_6, uc);
0 29 GET_UCHAR(BZ_X_BLKHDR_6, uc);
236 0 29 if (uc != 0x59) RETURN(BZ_DATA_ERROR);
243 29 39 GET_UCHAR(BZ_X_BCRC_1, uc);
10 29 GET_UCHAR(BZ_X_BCRC_1, uc);
0 29 GET_UCHAR(BZ_X_BCRC_1, uc);
245 29 39 GET_UCHAR(BZ_X_BCRC_2, uc);
10 29 GET_UCHAR(BZ_X_BCRC_2, uc);
0 29 GET_UCHAR(BZ_X_BCRC_2, uc);
247 29 39 GET_UCHAR(BZ_X_BCRC_3, uc);
10 29 GET_UCHAR(BZ_X_BCRC_3, uc);
0 29 GET_UCHAR(BZ_X_BCRC_3, uc);
249 29 39 GET_UCHAR(BZ_X_BCRC_4, uc);
10 29 GET_UCHAR(BZ_X_BCRC_4, uc);
0 29 GET_UCHAR(BZ_X_BCRC_4, uc);
252 29 39 GET_BITS(BZ_X_RANDBIT, s->blockRandomised, 1);
10 29 GET_BITS(BZ_X_RANDBIT, s->blockRandomised, 1);
0 29 GET_BITS(BZ_X_RANDBIT, s->blockRandomised, 1);
255 29 39 GET_UCHAR(BZ_X_ORIGPTR_1, uc);
10 29 GET_UCHAR(BZ_X_ORIGPTR_1, uc);
0 29 GET_UCHAR(BZ_X_ORIGPTR_1, uc);
257 29 39 GET_UCHAR(BZ_X_ORIGPTR_2, uc);
10 29 GET_UCHAR(BZ_X_ORIGPTR_2, uc);
0 29 GET_UCHAR(BZ_X_ORIGPTR_2, uc);
259 29 39 GET_UCHAR(BZ_X_ORIGPTR_3, uc);
10 29 GET_UCHAR(BZ_X_ORIGPTR_3, uc);
0 29 GET_UCHAR(BZ_X_ORIGPTR_3, uc);
262 0 29 if (s->origPtr < 0)
264 0 29 if (s->origPtr > 10 + 100000*s->blockSize100k)
268 464 29 for (i = 0; i < 16; i++) {
269 464 78 GET_BIT(BZ_X_MAPPING_1, uc);
20 58 GET_BIT(BZ_X_MAPPING_1, uc);
0 58 GET_BIT(BZ_X_MAPPING_1, uc);
270 180 284 if (uc == 1)
275 7424 29 for (i = 0; i < 256; i++) s->inUse[i] = False;
277 464 29 for (i = 0; i < 16; i++)
278 180 284 if (s->inUse16[i])
279 2880 180 for (j = 0; j < 16; j++) {
280 2880 474 GET_BIT(BZ_X_MAPPING_2, uc);
114 360 GET_BIT(BZ_X_MAPPING_2, uc);
0 360 GET_BIT(BZ_X_MAPPING_2, uc);
281 1400 1480 if (uc == 1) s->inUse[i * 16 + j] = True;
284 0 29 if (s->nInUse == 0) RETURN(BZ_DATA_ERROR);
288 29 0 GET_BITS(BZ_X_SELECTOR_1, nGroups, 3);
0 0 GET_BITS(BZ_X_SELECTOR_1, nGroups, 3);
0 0 GET_BITS(BZ_X_SELECTOR_1, nGroups, 3);
289 29 0 if (nGroups < 2 || nGroups > BZ_N_GROUPS) RETURN(BZ_DATA_ERROR);
0 29 if (nGroups < 2 || nGroups > BZ_N_GROUPS) RETURN(BZ_DATA_ERROR);
290 29 78 GET_BITS(BZ_X_SELECTOR_2, nSelectors, 15);
20 58 GET_BITS(BZ_X_SELECTOR_2, nSelectors, 15);
0 58 GET_BITS(BZ_X_SELECTOR_2, nSelectors, 15);
291 0 29 if (nSelectors < 1) RETURN(BZ_DATA_ERROR);
292 2260 29 for (i = 0; i < nSelectors; i++) {
295 7556 1370 GET_BIT(BZ_X_SELECTOR_3, uc);
427 943 GET_BIT(BZ_X_SELECTOR_3, uc);
0 943 GET_BIT(BZ_X_SELECTOR_3, uc);
296 2260 5296 if (uc == 0) break;
298 0 5296 if (j >= nGroups) RETURN(BZ_DATA_ERROR);
303 2260 0 if (i < BZ_MAX_SELECTORS)
306 0 29 if (nSelectors > BZ_MAX_SELECTORS)
312 81 29 for (v = 0; v < nGroups; v++) pos[v] = v;
314 2260 29 for (i = 0; i < nSelectors; i++) {
317 5296 2260 while (v > 0) { pos[v] = pos[v-1]; v--; }
324 81 29 for (t = 0; t < nGroups; t++) {
325 81 58 GET_BITS(BZ_X_CODING_1, curr, 5);
15 43 GET_BITS(BZ_X_CODING_1, curr, 5);
0 43 GET_BITS(BZ_X_CODING_1, curr, 5);
326 7154 81 for (i = 0; i < alphaSize; i++) {
328 11476 0 if (curr < 1 || curr > 20) RETURN(BZ_DATA_ERROR);
0 11476 if (curr < 1 || curr > 20) RETURN(BZ_DATA_ERROR);
329 11476 1739 GET_BIT(BZ_X_CODING_2, uc);
322 1417 GET_BIT(BZ_X_CODING_2, uc);
0 1417 GET_BIT(BZ_X_CODING_2, uc);
330 7154 4322 if (uc == 0) break;
331 4322 667 GET_BIT(BZ_X_CODING_3, uc);
103 564 GET_BIT(BZ_X_CODING_3, uc);
0 564 GET_BIT(BZ_X_CODING_3, uc);
332 2211 2111 if (uc == 0) curr++; else curr--;
339 81 29 for (t = 0; t < nGroups; t++) {
342 7154 81 for (i = 0; i < alphaSize; i++) {
343 122 7032 if (s->len[t][i] > maxLen) maxLen = s->len[t][i];
344 187 6967 if (s->len[t][i] < minLen) minLen = s->len[t][i];
363 7424 29 for (i = 0; i <= 255; i++) s->unzftab[i] = 0;
369 464 29 for (ii = 256 / MTFL_SIZE - 1; ii >= 0; ii--) {
370 7424 464 for (jj = MTFL_SIZE-1; jj >= 0; jj--) {
380 29 0 GET_MTF_VAL(BZ_X_MTF_1, BZ_X_MTF_2, nextSym);
0 29 GET_MTF_VAL(BZ_X_MTF_1, BZ_X_MTF_2, nextSym);
29 11 GET_MTF_VAL(BZ_X_MTF_1, BZ_X_MTF_2, nextSym);
1 10 GET_MTF_VAL(BZ_X_MTF_1, BZ_X_MTF_2, nextSym);
0 10 GET_MTF_VAL(BZ_X_MTF_1, BZ_X_MTF_2, nextSym);
0 68 GET_MTF_VAL(BZ_X_MTF_1, BZ_X_MTF_2, nextSym);
29 39 GET_MTF_VAL(BZ_X_MTF_1, BZ_X_MTF_2, nextSym);
39 2 GET_MTF_VAL(BZ_X_MTF_1, BZ_X_MTF_2, nextSym);
0 2 GET_MTF_VAL(BZ_X_MTF_1, BZ_X_MTF_2, nextSym);
0 2 GET_MTF_VAL(BZ_X_MTF_1, BZ_X_MTF_2, nextSym);
29 0 GET_MTF_VAL(BZ_X_MTF_1, BZ_X_MTF_2, nextSym);
0 29 GET_MTF_VAL(BZ_X_MTF_1, BZ_X_MTF_2, nextSym);
384 29 110684 if (nextSym == EOB) break;
386 110245 439 if (nextSym == BZ_RUNA || nextSym == BZ_RUNB) {
167 110078 if (nextSym == BZ_RUNA || nextSym == BZ_RUNB) {
397 0 2030 if (N >= 2*1024*1024) RETURN(BZ_DATA_ERROR);
398 1049 981 if (nextSym == BZ_RUNA) es = es + (0+1) * N; else
399 981 0 if (nextSym == BZ_RUNB) es = es + (1+1) * N;
401 32 1998 GET_MTF_VAL(BZ_X_MTF_3, BZ_X_MTF_4, nextSym);
0 32 GET_MTF_VAL(BZ_X_MTF_3, BZ_X_MTF_4, nextSym);
2030 726 GET_MTF_VAL(BZ_X_MTF_3, BZ_X_MTF_4, nextSym);
165 561 GET_MTF_VAL(BZ_X_MTF_3, BZ_X_MTF_4, nextSym);
0 561 GET_MTF_VAL(BZ_X_MTF_3, BZ_X_MTF_4, nextSym);
0 3870 GET_MTF_VAL(BZ_X_MTF_3, BZ_X_MTF_4, nextSym);
2030 1840 GET_MTF_VAL(BZ_X_MTF_3, BZ_X_MTF_4, nextSym);
1840 262 GET_MTF_VAL(BZ_X_MTF_3, BZ_X_MTF_4, nextSym);
20 242 GET_MTF_VAL(BZ_X_MTF_3, BZ_X_MTF_4, nextSym);
0 242 GET_MTF_VAL(BZ_X_MTF_3, BZ_X_MTF_4, nextSym);
2030 0 GET_MTF_VAL(BZ_X_MTF_3, BZ_X_MTF_4, nextSym);
0 2030 GET_MTF_VAL(BZ_X_MTF_3, BZ_X_MTF_4, nextSym);
403 610 1420 while (nextSym == BZ_RUNA || nextSym == BZ_RUNB);
814 606 while (nextSym == BZ_RUNA || nextSym == BZ_RUNB);
409 0 606 if (s->smallDecompress)
410 0 0 while (es > 0) {
411 0 0 if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR);
417 353485 606 while (es > 0) {
418 0 353485 if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR);
428 0 110078 if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR);
436 6984 103094 if (nn < MTFL_SIZE) {
440 11038 6984 while (nn > 3) {
448 11291 6984 while (nn > 0) {
458 768340 103094 while (pp > s->mtfbase[lno]) {
462 821243 103094 while (lno > 0) {
470 26 103068 if (s->mtfbase[0] == 0) {
472 416 26 for (ii = 256 / MTFL_SIZE-1; ii >= 0; ii--) {
473 6656 416 for (jj = MTFL_SIZE-1; jj >= 0; jj--) {
485 0 110078 if (s->smallDecompress)
490 2199 107879 GET_MTF_VAL(BZ_X_MTF_5, BZ_X_MTF_6, nextSym);
0 2199 GET_MTF_VAL(BZ_X_MTF_5, BZ_X_MTF_6, nextSym);
110078 139876 GET_MTF_VAL(BZ_X_MTF_5, BZ_X_MTF_6, nextSym);
43970 95906 GET_MTF_VAL(BZ_X_MTF_5, BZ_X_MTF_6, nextSym);
0 95906 GET_MTF_VAL(BZ_X_MTF_5, BZ_X_MTF_6, nextSym);
0 219571 GET_MTF_VAL(BZ_X_MTF_5, BZ_X_MTF_6, nextSym);
110078 109493 GET_MTF_VAL(BZ_X_MTF_5, BZ_X_MTF_6, nextSym);
109493 18581 GET_MTF_VAL(BZ_X_MTF_5, BZ_X_MTF_6, nextSym);
5615 12966 GET_MTF_VAL(BZ_X_MTF_5, BZ_X_MTF_6, nextSym);
0 12966 GET_MTF_VAL(BZ_X_MTF_5, BZ_X_MTF_6, nextSym);
110078 0 GET_MTF_VAL(BZ_X_MTF_5, BZ_X_MTF_6, nextSym);
0 110078 GET_MTF_VAL(BZ_X_MTF_5, BZ_X_MTF_6, nextSym);
498 29 0 if (s->origPtr < 0 || s->origPtr >= nblock)
0 29 if (s->origPtr < 0 || s->origPtr >= nblock)
503 7424 29 for (i = 0; i <= 255; i++) {
504 7424 0 if (s->unzftab[i] < 0 || s->unzftab[i] > nblock)
0 7424 if (s->unzftab[i] < 0 || s->unzftab[i] > nblock)
509 7424 29 for (i = 1; i <= 256; i++) s->cftab[i] = s->unzftab[i-1];
510 7424 29 for (i = 1; i <= 256; i++) s->cftab[i] += s->cftab[i-1];
512 7453 29 for (i = 0; i <= 256; i++) {
513 7453 0 if (s->cftab[i] < 0 || s->cftab[i] > nblock) {
0 7453 if (s->cftab[i] < 0 || s->cftab[i] > nblock) {
519 7424 29 for (i = 1; i <= 256; i++) {
520 0 7424 if (s->cftab[i-1] > s->cftab[i]) {
531 0 29 if (s->smallDecompress) {
534 0 0 for (i = 0; i <= 256; i++) s->cftabCopy[i] = s->cftab[i];
537 0 0 for (i = 0; i < nblock; i++) {
539 0 0 SET_LL(i, s->cftabCopy[uc]);
548 0 0 SET_LL(j, i);
552 0 0 while (i != s->origPtr);
556 0 0 if (s->blockRandomised) {
558 0 0 BZ_GET_SMALL(s->k0); s->nblock_used++;
559 0 0 BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK;
0 0 BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK;
561 0 0 BZ_GET_SMALL(s->k0); s->nblock_used++;
567 463563 29 for (i = 0; i < nblock; i++) {
575 0 29 if (s->blockRandomised) {
577 0 0 BZ_GET_FAST(s->k0); s->nblock_used++;
578 0 0 BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK;
0 0 BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK;
580 0 29 BZ_GET_FAST(s->k0); s->nblock_used++;
591 29 39 GET_UCHAR(BZ_X_ENDHDR_2, uc);
10 29 GET_UCHAR(BZ_X_ENDHDR_2, uc);
0 29 GET_UCHAR(BZ_X_ENDHDR_2, uc);
592 0 29 if (uc != 0x72) RETURN(BZ_DATA_ERROR);
593 29 39 GET_UCHAR(BZ_X_ENDHDR_3, uc);
10 29 GET_UCHAR(BZ_X_ENDHDR_3, uc);
0 29 GET_UCHAR(BZ_X_ENDHDR_3, uc);
594 0 29 if (uc != 0x45) RETURN(BZ_DATA_ERROR);
595 29 39 GET_UCHAR(BZ_X_ENDHDR_4, uc);
10 29 GET_UCHAR(BZ_X_ENDHDR_4, uc);
0 29 GET_UCHAR(BZ_X_ENDHDR_4, uc);
596 0 29 if (uc != 0x38) RETURN(BZ_DATA_ERROR);
597 29 39 GET_UCHAR(BZ_X_ENDHDR_5, uc);
10 29 GET_UCHAR(BZ_X_ENDHDR_5, uc);
0 29 GET_UCHAR(BZ_X_ENDHDR_5, uc);
598 0 29 if (uc != 0x50) RETURN(BZ_DATA_ERROR);
599 29 39 GET_UCHAR(BZ_X_ENDHDR_6, uc);
10 29 GET_UCHAR(BZ_X_ENDHDR_6, uc);
0 29 GET_UCHAR(BZ_X_ENDHDR_6, uc);
600 0 29 if (uc != 0x90) RETURN(BZ_DATA_ERROR);
603 29 39 GET_UCHAR(BZ_X_CCRC_1, uc);
10 29 GET_UCHAR(BZ_X_CCRC_1, uc);
0 29 GET_UCHAR(BZ_X_CCRC_1, uc);
605 29 39 GET_UCHAR(BZ_X_CCRC_2, uc);
10 29 GET_UCHAR(BZ_X_CCRC_2, uc);
0 29 GET_UCHAR(BZ_X_CCRC_2, uc);
607 29 39 GET_UCHAR(BZ_X_CCRC_3, uc);
10 29 GET_UCHAR(BZ_X_CCRC_3, uc);
0 29 GET_UCHAR(BZ_X_CCRC_3, uc);
609 29 39 GET_UCHAR(BZ_X_CCRC_4, uc);
10 29 GET_UCHAR(BZ_X_CCRC_4, uc);
0 29 GET_UCHAR(BZ_X_CCRC_4, uc);