Branch Coverage

inflate.c
Criterion Covered Total %
branch 301 554 54.3


line true false branch
109 101309 0 if (strm == Z_NULL ||
101309 0 if (strm == Z_NULL ||
110 0 101309 strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)
113 101309 0 if (state == Z_NULL || state->strm != strm ||
101309 0 if (state == Z_NULL || state->strm != strm ||
101309 0 if (state == Z_NULL || state->strm != strm ||
114 0 101309 state->mode < HEAD || state->mode > SYNC)
124 0 47 if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
128 42 5 if (state->wrap) /* to support ill-conceived Java test suite */
150 0 47 if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
166 0 45 if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
170 3 42 if (windowBits < 0) {
171 0 3 if (windowBits < -15)
179 42 0 if (windowBits < 48)
185 45 0 if (windowBits && (windowBits < 8 || windowBits > 15))
45 0 if (windowBits && (windowBits < 8 || windowBits > 15))
0 45 if (windowBits && (windowBits < 8 || windowBits > 15))
187 0 45 if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) {
0 0 if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) {
207 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] ||
210 0 45 if (strm == Z_NULL) return Z_STREAM_ERROR;
212 0 45 if (strm->zalloc == (alloc_func)0) {
220 0 45 if (strm->zfree == (free_func)0)
228 0 45 if (state == Z_NULL) return Z_MEM_ERROR;
235 0 45 if (ret != Z_OK) {
257 0 0 if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
259 0 0 if (bits < 0) {
264 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;
410 35 100781 if (state->window == Z_NULL) {
414 0 35 if (state->window == Z_NULL) return 1;
418 35 100781 if (state->wsize == 0) {
425 1 100815 if (copy >= state->wsize) {
432 100808 7 if (dist > copy) dist = copy;
435 6 100809 if (copy) {
442 1 100808 if (state->wnext == state->wsize) state->wnext = 0;
443 66317 34492 if (state->whave < state->wsize) state->whave += dist;
648 100954 0 if (inflateStateCheck(strm) || strm->next_out == Z_NULL ||
100954 0 if (inflateStateCheck(strm) || strm->next_out == Z_NULL ||
0 100954 if (inflateStateCheck(strm) || strm->next_out == Z_NULL ||
649 0 0 (strm->next_in == Z_NULL && strm->avail_in != 0))
653 15 100939 if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */
661 2 63 if (state->wrap == 0) {
665 24 80 NEEDBITS(16);
104 39 NEEDBITS(16);
667 5 34 if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */
3 2 if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */
668 0 3 if (state->wbits == 0)
676 0 36 if (state->head != Z_NULL)
678 35 1 if (!(state->wrap & 1) || /* check if zlib header allowed */
2 33 if (!(state->wrap & 1) || /* check if zlib header allowed */
687 0 33 if (BITS(4) != Z_DEFLATED) {
694 0 33 if (state->wbits == 0)
696 33 0 if (len > 15 || len > state->wbits) {
0 33 if (len > 15 || len > state->wbits) {
705 1 32 state->mode = hold & 0x200 ? DICTID : TYPE;
710 0 6 NEEDBITS(16);
6 3 NEEDBITS(16);
712 0 3 if ((state->flags & 0xff) != Z_DEFLATED) {
717 0 3 if (state->flags & 0xe000) {
722 0 3 if (state->head != Z_NULL)
724 0 3 if ((state->flags & 0x0200) && (state->wrap & 4))
0 0 if ((state->flags & 0x0200) && (state->wrap & 4))
730 0 12 NEEDBITS(32);
12 3 NEEDBITS(32);
731 0 3 if (state->head != Z_NULL)
733 0 3 if ((state->flags & 0x0200) && (state->wrap & 4))
0 0 if ((state->flags & 0x0200) && (state->wrap & 4))
739 0 6 NEEDBITS(16);
6 3 NEEDBITS(16);
740 0 3 if (state->head != Z_NULL) {
744 0 3 if ((state->flags & 0x0200) && (state->wrap & 4))
0 0 if ((state->flags & 0x0200) && (state->wrap & 4))
750 0 3 if (state->flags & 0x0400) {
751 0 0 NEEDBITS(16);
0 0 NEEDBITS(16);
753 0 0 if (state->head != Z_NULL)
755 0 0 if ((state->flags & 0x0200) && (state->wrap & 4))
0 0 if ((state->flags & 0x0200) && (state->wrap & 4))
759 0 3 else if (state->head != Z_NULL)
764 0 3 if (state->flags & 0x0400) {
766 0 0 if (copy > have) copy = have;
767 0 0 if (copy) {
768 0 0 if (state->head != Z_NULL &&
0 0 if (state->head != Z_NULL &&
769 0 0 state->head->extra != Z_NULL &&
772 0 0 zmemcpy(state->head->extra + len, next,
776 0 0 if ((state->flags & 0x0200) && (state->wrap & 4))
0 0 if ((state->flags & 0x0200) && (state->wrap & 4))
782 0 0 if (state->length) goto inf_leave;
788 0 3 if (state->flags & 0x0800) {
789 0 0 if (have == 0) goto inf_leave;
793 0 0 if (state->head != Z_NULL &&
0 0 if (state->head != Z_NULL &&
794 0 0 state->head->name != Z_NULL &&
797 0 0 } while (len && copy < have);
0 0 } while (len && copy < have);
798 0 0 if ((state->flags & 0x0200) && (state->wrap & 4))
0 0 if ((state->flags & 0x0200) && (state->wrap & 4))
802 0 0 if (len) goto inf_leave;
804 0 3 else if (state->head != Z_NULL)
810 0 3 if (state->flags & 0x1000) {
811 0 0 if (have == 0) goto inf_leave;
815 0 0 if (state->head != Z_NULL &&
0 0 if (state->head != Z_NULL &&
816 0 0 state->head->comment != Z_NULL &&
819 0 0 } while (len && copy < have);
0 0 } while (len && copy < have);
820 0 0 if ((state->flags & 0x0200) && (state->wrap & 4))
0 0 if ((state->flags & 0x0200) && (state->wrap & 4))
824 0 0 if (len) goto inf_leave;
826 0 3 else if (state->head != Z_NULL)
831 0 3 if (state->flags & 0x0200) {
832 0 0 NEEDBITS(16);
0 0 NEEDBITS(16);
833 0 0 if ((state->wrap & 4) && hold != (state->check & 0xffff)) {
0 0 if ((state->wrap & 4) && hold != (state->check & 0xffff)) {
840 0 3 if (state->head != Z_NULL) {
849 0 4 NEEDBITS(32);
4 1 NEEDBITS(32);
855 1 1 if (state->havedict == 0) {
863 80 0 if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
80 0 if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
866 39 71 if (state->last) {
871 26 44 NEEDBITS(3);
70 45 NEEDBITS(3);
885 0 25 if (flush == Z_TREES) {
903 16 32 NEEDBITS(32);
48 8 NEEDBITS(32);
904 0 8 if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
914 0 8 if (flush == Z_TREES) goto inf_leave;
921 150018 8 if (copy) {
922 149998 20 if (copy > have) copy = have;
923 12 150006 if (copy > left) copy = left;
924 100006 50012 if (copy == 0) goto inf_leave;
937 4 24 NEEDBITS(14);
28 12 NEEDBITS(14);
945 12 0 if (state->nlen > 286 || state->ndist > 30) {
0 12 if (state->nlen > 286 || state->ndist > 30) {
956 228 12 while (state->have < state->ncode) {
957 12 73 NEEDBITS(3);
85 216 NEEDBITS(3);
961 12 12 while (state->have < 19)
968 0 12 if (ret) {
978 447 12 while (state->have < state->nlen + state->ndist) {
981 427 147 if ((unsigned)(here.bits) <= bits) break;
982 20 127 PULLBYTE();
984 288 139 if (here.val < 16) {
989 1 138 if (here.val == 16) {
990 0 1 NEEDBITS(here.bits + 2);
1 1 NEEDBITS(here.bits + 2);
992 0 1 if (state->have == 0) {
1001 72 66 else if (here.val == 17) {
1002 6 45 NEEDBITS(here.bits + 3);
51 66 NEEDBITS(here.bits + 3);
1009 8 39 NEEDBITS(here.bits + 7);
47 58 NEEDBITS(here.bits + 7);
1015 0 125 if (state->have + copy > state->nlen + state->ndist) {
1020 3242 125 while (copy--)
1026 0 12 if (state->mode == BAD) break;
1029 0 12 if (state->lens[256] == 0) {
1043 0 12 if (ret) {
1052 0 12 if (ret) {
1059 0 12 if (flush == Z_TREES) goto inf_leave;
1065 461 788 if (have >= 6 && left >= 258) {
129 332 if (have >= 6 && left >= 258) {
1069 10 119 if (state->mode == TYPE)
1076 678 875 if ((unsigned)(here.bits) <= bits) break;
1077 442 433 PULLBYTE();
1079 235 443 if (here.op && (here.op & 0xf0) == 0) {
0 235 if (here.op && (here.op & 0xf0) == 0) {
1084 0 0 if ((unsigned)(last.bits + here.bits) <= bits) break;
1085 0 0 PULLBYTE();
1093 443 235 if ((int)(here.op) == 0) {
1100 26 209 if (here.op & 32) {
1106 0 209 if (here.op & 64) {
1115 4 207 if (state->extra) {
1116 2 1 NEEDBITS(state->extra);
3 2 NEEDBITS(state->extra);
1128 209 21 if ((unsigned)(here.bits) <= bits) break;
1129 0 21 PULLBYTE();
1131 0 209 if ((here.op & 0xf0) == 0) {
1136 0 0 if ((unsigned)(last.bits + here.bits) <= bits) break;
1137 0 0 PULLBYTE();
1144 0 209 if (here.op & 64) {
1154 312 1 if (state->extra) {
1155 104 78 NEEDBITS(state->extra);
182 208 NEEDBITS(state->extra);
1171 142 526 if (left == 0) goto inf_leave;
1173 203 323 if (state->offset > copy) { /* copy from window */
1175 0 203 if (copy > state->whave) {
1176 0 0 if (state->sane) {
1195 1 202 if (copy > state->wnext) {
1201 9 194 if (copy > state->length) copy = state->length;
1207 135 391 if (copy > left) copy = left;
1212 52645 526 } while (--copy);
1213 208 318 if (state->length == 0) state->mode = LEN;
1216 19 443 if (left == 0) goto inf_leave;
1222 116 3 if (state->wrap) {
1223 80 144 NEEDBITS(32);
224 36 NEEDBITS(32);
1227 36 0 if ((state->wrap & 4) && out)
26 10 if ((state->wrap & 4) && out)
1229 3 23 UPDATE_CHECK(state->check, put - out, out);
1231 36 0 if ((state->wrap & 4) && (
0 36 if ((state->wrap & 4) && (
1233 33 3 state->flags ? hold :
1247 36 3 if (state->wrap && state->flags) {
3 33 if (state->wrap && state->flags) {
1248 0 12 NEEDBITS(32);
12 3 NEEDBITS(32);
1249 3 0 if ((state->wrap & 4) && hold != (state->total & 0xffffffff)) {
0 3 if ((state->wrap & 4) && hold != (state->total & 0xffffffff)) {
1282 172 100781 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 &&
1 33 if (state->wsize || (out != strm->avail_out && state->mode < BAD &&
1283 1 0 (state->mode < CHECK || flush != Z_FINISH)))
1284 0 100815 if (updatewindow(strm, strm->next_out, out - strm->avail_out)) {
1293 100756 197 if ((state->wrap & 4) && out)
50357 50399 if ((state->wrap & 4) && out)
1295 2 50355 UPDATE_CHECK(state->check, strm->next_out - out, out);
1296 35320 65633 strm->data_type = (int)state->bits + (state->last ? 64 : 0) +
1297 13 100940 (state->mode == TYPE ? 128 : 0) +
1298 100953 0 (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
0 100953 (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
1299 50417 50536 if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
45 50372 if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
0 50581 if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
50372 0 if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
1308 0 45 if (inflateStateCheck(strm))
1311 35 10 if (state->window != Z_NULL) ZFREE(strm, state->window);
1326 0 0 if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
1330 0 0 if (state->whave && dictionary != Z_NULL) {
0 0 if (state->whave && dictionary != Z_NULL) {
1336 0 0 if (dictLength != Z_NULL)
1351 0 1 if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
1353 1 0 if (state->wrap != 0 && state->mode != DICT)
0 1 if (state->wrap != 0 && state->mode != DICT)
1357 1 0 if (state->mode == DICT) {
1360 0 1 if (dictid != state->check)
1367 0 1 if (ret) {
1383 0 0 if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
1385 0 0 if ((state->wrap & 2) == 0) return Z_STREAM_ERROR;
1414 353 172 while (next < len && got < 4) {
352 1 while (next < len && got < 4) {
1415 348 4 if ((int)(buf[next]) == (got < 2 ? 0 : 0xff))
8 344 if ((int)(buf[next]) == (got < 2 ? 0 : 0xff))
1417 344 0 else if (buf[next])
1437 0 170 if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
1439 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;
1442 3 167 if (state->mode != SYNC) {
1447 4 3 while (state->bits >= 8) {
1463 168 2 if (state->have != 4) return Z_DATA_ERROR;
1464 2 0 if (state->flags == -1)
1490 0 0 if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
1492 0 0 return state->mode == STORED && state->bits == 0;
0 0 return state->mode == STORED && state->bits == 0;
1505 0 0 if (inflateStateCheck(source) || dest == Z_NULL)
0 0 if (inflateStateCheck(source) || dest == Z_NULL)
1512 0 0 if (copy == Z_NULL) return Z_MEM_ERROR;
1514 0 0 if (state->window != Z_NULL) {
1517 0 0 if (window == Z_NULL) {
1527 0 0 if (state->lencode >= state->codes &&
0 0 if (state->lencode >= state->codes &&
1533 0 0 if (window != Z_NULL) {
1548 0 0 if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
1566 0 0 if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
1568 0 0 if (check && state->wrap)
0 0 if (check && state->wrap)
1580 0 0 if (inflateStateCheck(strm))
1583 0 0 return (long)(((unsigned long)((long)state->back)) << 16) +
0 0 return (long)(((unsigned long)((long)state->back)) << 16) +
1592 0 0 if (inflateStateCheck(strm)) return (unsigned long)-1;