Branch Coverage

inflate.c
Criterion Covered Total %
branch 301 556 54.1


line true false branch
90 101302 0 if (strm == Z_NULL ||
91 101302 0 strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)
0 101302 strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)
94 101302 0 if (state == Z_NULL || state->strm != strm ||
101302 0 if (state == Z_NULL || state->strm != strm ||
95 101302 0 state->mode < HEAD || state->mode > SYNC)
0 101302 state->mode < HEAD || state->mode > SYNC)
103 0 47 if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
108 42 5 if (state->wrap) /* to support ill-conceived Java test suite */
128 0 47 if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
141 0 45 if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
145 3 42 if (windowBits < 0) {
146 0 3 if (windowBits < -15)
154 42 0 if (windowBits < 48)
160 45 0 if (windowBits && (windowBits < 8 || windowBits > 15))
45 0 if (windowBits && (windowBits < 8 || windowBits > 15))
0 45 if (windowBits && (windowBits < 8 || windowBits > 15))
162 0 45 if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) {
0 0 if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) {
178 45 0 if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
45 0 if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
0 45 if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
181 0 45 if (strm == Z_NULL) return Z_STREAM_ERROR;
183 0 45 if (strm->zalloc == (alloc_func)0) {
191 0 45 if (strm->zfree == (free_func)0)
199 0 45 if (state == Z_NULL) return Z_MEM_ERROR;
207 0 45 if (ret != Z_OK) {
222 0 0 if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
223 0 0 if (bits == 0)
226 0 0 if (bits < 0) {
231 0 0 if (bits > 16 || state->bits + (uInt)bits > 32) return Z_STREAM_ERROR;
0 0 if (bits > 16 || state->bits + (uInt)bits > 32) return Z_STREAM_ERROR;
259 35 100774 if (state->window == Z_NULL) {
263 0 35 if (state->window == Z_NULL) return 1;
267 35 100774 if (state->wsize == 0) {
274 1 100808 if (copy >= state->wsize) {
281 100801 7 if (dist > copy) dist = copy;
284 6 100802 if (copy) {
291 1 100801 if (state->wnext == state->wsize) state->wnext = 0;
292 66309 34493 if (state->whave < state->wsize) state->whave += dist;
494 100947 0 if (inflateStateCheck(strm) || strm->next_out == Z_NULL ||
100947 0 if (inflateStateCheck(strm) || strm->next_out == Z_NULL ||
495 0 100947 (strm->next_in == Z_NULL && strm->avail_in != 0))
0 0 (strm->next_in == Z_NULL && strm->avail_in != 0))
499 15 100932 if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */
507 2 63 if (state->wrap == 0) {
511 24 80 NEEDBITS(16);
104 39 NEEDBITS(16);
513 5 34 if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */
3 2 if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */
514 0 3 if (state->wbits == 0)
522 0 36 if (state->head != Z_NULL)
524 35 1 if (!(state->wrap & 1) || /* check if zlib header allowed */
528 2 33 ((BITS(8) << 8) + (hold >> 8)) % 31) {
533 0 33 if (BITS(4) != Z_DEFLATED) {
540 0 33 if (state->wbits == 0)
542 33 0 if (len > 15 || len > state->wbits) {
0 33 if (len > 15 || len > state->wbits) {
551 1 32 state->mode = hold & 0x200 ? DICTID : TYPE;
556 0 6 NEEDBITS(16);
6 3 NEEDBITS(16);
558 0 3 if ((state->flags & 0xff) != Z_DEFLATED) {
563 0 3 if (state->flags & 0xe000) {
568 0 3 if (state->head != Z_NULL)
570 0 3 if ((state->flags & 0x0200) && (state->wrap & 4))
0 0 if ((state->flags & 0x0200) && (state->wrap & 4))
576 0 12 NEEDBITS(32);
12 3 NEEDBITS(32);
577 0 3 if (state->head != Z_NULL)
579 0 3 if ((state->flags & 0x0200) && (state->wrap & 4))
0 0 if ((state->flags & 0x0200) && (state->wrap & 4))
585 0 6 NEEDBITS(16);
6 3 NEEDBITS(16);
586 0 3 if (state->head != Z_NULL) {
590 0 3 if ((state->flags & 0x0200) && (state->wrap & 4))
0 0 if ((state->flags & 0x0200) && (state->wrap & 4))
596 0 3 if (state->flags & 0x0400) {
597 0 0 NEEDBITS(16);
0 0 NEEDBITS(16);
599 0 0 if (state->head != Z_NULL)
601 0 0 if ((state->flags & 0x0200) && (state->wrap & 4))
0 0 if ((state->flags & 0x0200) && (state->wrap & 4))
605 0 3 else if (state->head != Z_NULL)
610 0 3 if (state->flags & 0x0400) {
612 0 0 if (copy > have) copy = have;
613 0 0 if (copy) {
614 0 0 if (state->head != Z_NULL &&
615 0 0 state->head->extra != Z_NULL &&
617 0 0 state->head->extra_max) {
619 0 0 len + copy > state->head->extra_max ?
622 0 0 if ((state->flags & 0x0200) && (state->wrap & 4))
0 0 if ((state->flags & 0x0200) && (state->wrap & 4))
628 0 0 if (state->length) goto inf_leave;
634 0 3 if (state->flags & 0x0800) {
635 0 0 if (have == 0) goto inf_leave;
639 0 0 if (state->head != Z_NULL &&
640 0 0 state->head->name != Z_NULL &&
641 0 0 state->length < state->head->name_max)
643 0 0 } while (len && copy < have);
0 0 } while (len && copy < have);
644 0 0 if ((state->flags & 0x0200) && (state->wrap & 4))
0 0 if ((state->flags & 0x0200) && (state->wrap & 4))
648 0 0 if (len) goto inf_leave;
650 0 3 else if (state->head != Z_NULL)
656 0 3 if (state->flags & 0x1000) {
657 0 0 if (have == 0) goto inf_leave;
661 0 0 if (state->head != Z_NULL &&
662 0 0 state->head->comment != Z_NULL &&
663 0 0 state->length < state->head->comm_max)
665 0 0 } while (len && copy < have);
0 0 } while (len && copy < have);
666 0 0 if ((state->flags & 0x0200) && (state->wrap & 4))
0 0 if ((state->flags & 0x0200) && (state->wrap & 4))
670 0 0 if (len) goto inf_leave;
672 0 3 else if (state->head != Z_NULL)
677 0 3 if (state->flags & 0x0200) {
678 0 0 NEEDBITS(16);
0 0 NEEDBITS(16);
679 0 0 if ((state->wrap & 4) && hold != (state->check & 0xffff)) {
0 0 if ((state->wrap & 4) && hold != (state->check & 0xffff)) {
686 0 3 if (state->head != Z_NULL) {
695 0 4 NEEDBITS(32);
4 1 NEEDBITS(32);
701 1 1 if (state->havedict == 0) {
709 80 0 if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
0 80 if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
712 39 71 if (state->last) {
717 26 44 NEEDBITS(3);
70 45 NEEDBITS(3);
731 0 25 if (flush == Z_TREES) {
749 16 32 NEEDBITS(32);
48 8 NEEDBITS(32);
750 0 8 if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
760 0 8 if (flush == Z_TREES) goto inf_leave;
767 150018 8 if (copy) {
768 149998 20 if (copy > have) copy = have;
769 12 150006 if (copy > left) copy = left;
770 100006 50012 if (copy == 0) goto inf_leave;
783 4 24 NEEDBITS(14);
28 12 NEEDBITS(14);
791 12 0 if (state->nlen > 286 || state->ndist > 30) {
0 12 if (state->nlen > 286 || state->ndist > 30) {
803 228 12 while (state->have < state->ncode) {
804 12 73 NEEDBITS(3);
85 216 NEEDBITS(3);
808 12 12 while (state->have < 19)
815 0 12 if (ret) {
825 447 12 while (state->have < state->nlen + state->ndist) {
828 427 147 if ((unsigned)(here.bits) <= bits) break;
829 20 127 PULLBYTE();
831 288 139 if (here.val < 16) {
836 1 138 if (here.val == 16) {
837 0 1 NEEDBITS(here.bits + 2);
1 1 NEEDBITS(here.bits + 2);
839 0 1 if (state->have == 0) {
849 72 66 else if (here.val == 17) {
850 6 45 NEEDBITS(here.bits + 3);
51 66 NEEDBITS(here.bits + 3);
857 8 39 NEEDBITS(here.bits + 7);
47 58 NEEDBITS(here.bits + 7);
863 0 125 if (state->have + copy > state->nlen + state->ndist) {
869 3242 125 while (copy--)
875 0 12 if (state->mode == BAD) break;
878 0 12 if (state->lens[256] == 0) {
893 0 12 if (ret) {
902 0 12 if (ret) {
909 0 12 if (flush == Z_TREES) goto inf_leave;
915 529 788 if (have >= 6 && left >= 258) {
125 404 if (have >= 6 && left >= 258) {
919 10 115 if (state->mode == TYPE)
926 750 942 if ((unsigned)(here.bits) <= bits) break;
927 442 500 PULLBYTE();
929 235 515 if (here.op && (here.op & 0xf0) == 0) {
0 235 if (here.op && (here.op & 0xf0) == 0) {
934 0 0 if ((unsigned)(last.bits + here.bits) <= bits) break;
935 0 0 PULLBYTE();
943 515 235 if ((int)(here.op) == 0) {
950 26 209 if (here.op & 32) {
956 0 209 if (here.op & 64) {
965 4 207 if (state->extra) {
966 2 1 NEEDBITS(state->extra);
3 2 NEEDBITS(state->extra);
978 209 22 if ((unsigned)(here.bits) <= bits) break;
979 0 22 PULLBYTE();
981 0 209 if ((here.op & 0xf0) == 0) {
986 0 0 if ((unsigned)(last.bits + here.bits) <= bits) break;
987 0 0 PULLBYTE();
994 0 209 if (here.op & 64) {
1004 312 1 if (state->extra) {
1005 104 70 NEEDBITS(state->extra);
174 208 NEEDBITS(state->extra);
1021 138 516 if (left == 0) goto inf_leave;
1023 195 321 if (state->offset > copy) { /* copy from window */
1025 0 195 if (copy > state->whave) {
1026 0 0 if (state->sane) {
1046 1 194 if (copy > state->wnext) {
1052 13 182 if (copy > state->length) copy = state->length;
1058 130 386 if (copy > left) copy = left;
1063 52655 516 } while (--copy);
1064 208 308 if (state->length == 0) state->mode = LEN;
1067 16 515 if (left == 0) goto inf_leave;
1073 116 3 if (state->wrap) {
1074 80 144 NEEDBITS(32);
224 36 NEEDBITS(32);
1078 36 0 if ((state->wrap & 4) && out)
26 10 if ((state->wrap & 4) && out)
1080 3 23 UPDATE_CHECK(state->check, put - out, out);
1082 36 0 if ((state->wrap & 4) && (
1084 33 3 state->flags ? hold :
1086 0 36 ZSWAP32(hold)) != state->check) {
1098 36 3 if (state->wrap && state->flags) {
3 33 if (state->wrap && state->flags) {
1099 0 12 NEEDBITS(32);
12 3 NEEDBITS(32);
1100 3 0 if ((state->wrap & 4) && hold != (state->total & 0xffffffff)) {
0 3 if ((state->wrap & 4) && hold != (state->total & 0xffffffff)) {
1133 172 100774 if (state->wsize || (out != strm->avail_out && state->mode < BAD &&
34 138 if (state->wsize || (out != strm->avail_out && state->mode < BAD &&
34 0 if (state->wsize || (out != strm->avail_out && state->mode < BAD &&
1134 1 33 (state->mode < CHECK || flush != Z_FINISH)))
1 0 (state->mode < CHECK || flush != Z_FINISH)))
1135 0 100808 if (updatewindow(strm, strm->next_out, out - strm->avail_out)) {
1144 100749 197 if ((state->wrap & 4) && out)
50350 50399 if ((state->wrap & 4) && out)
1146 2 50348 UPDATE_CHECK(state->check, strm->next_out - out, out);
1147 35309 65637 strm->data_type = (int)state->bits + (state->last ? 64 : 0) +
1148 13 100933 (state->mode == TYPE ? 128 : 0) +
1149 100946 0 (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
0 100946 (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
1150 50413 50533 if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
41 50372 if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
0 50574 if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
50372 0 if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
1157 0 45 if (inflateStateCheck(strm))
1160 35 10 if (state->window != Z_NULL) ZFREE(strm, state->window);
1172 0 0 if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
1176 0 0 if (state->whave && dictionary != Z_NULL) {
0 0 if (state->whave && dictionary != Z_NULL) {
1182 0 0 if (dictLength != Z_NULL)
1194 0 1 if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
1196 1 0 if (state->wrap != 0 && state->mode != DICT)
0 1 if (state->wrap != 0 && state->mode != DICT)
1200 1 0 if (state->mode == DICT) {
1203 0 1 if (dictid != state->check)
1210 0 1 if (ret) {
1223 0 0 if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
1225 0 0 if ((state->wrap & 2) == 0) return Z_STREAM_ERROR;
1251 353 172 while (next < len && got < 4) {
352 1 while (next < len && got < 4) {
1252 348 4 if ((int)(buf[next]) == (got < 2 ? 0 : 0xff))
8 344 if ((int)(buf[next]) == (got < 2 ? 0 : 0xff))
1254 344 0 else if (buf[next])
1272 0 170 if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
1274 0 170 if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR;
0 0 if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR;
1277 3 167 if (state->mode != SYNC) {
1282 4 3 while (state->bits >= 8) {
1298 168 2 if (state->have != 4) return Z_DATA_ERROR;
1299 2 0 if (state->flags == -1)
1323 0 0 if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
1325 0 0 return state->mode == STORED && state->bits == 0;
0 0 return state->mode == STORED && state->bits == 0;
1334 0 0 if (inflateStateCheck(source) || dest == Z_NULL)
0 0 if (inflateStateCheck(source) || dest == Z_NULL)
1341 0 0 if (copy == Z_NULL) return Z_MEM_ERROR;
1344 0 0 if (state->window != Z_NULL) {
1347 0 0 if (window == Z_NULL) {
1357 0 0 if (state->lencode >= state->codes &&
1358 0 0 state->lencode <= state->codes + ENOUGH - 1) {
1363 0 0 if (window != Z_NULL)
1373 0 0 if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
1388 0 0 if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
1390 0 0 if (check && state->wrap)
0 0 if (check && state->wrap)
1400 0 0 if (inflateStateCheck(strm))
1404 0 0 (state->mode == COPY ? state->length :
1405 0 0 (state->mode == MATCH ? state->was - state->length : 0));
1410 0 0 if (inflateStateCheck(strm)) return (unsigned long)-1;