goto finished;
nlen = dctx->bits & 0xFFFF;
EATBITS(16);
- if (dctx->uncomplen == 0)
- dctx->state = OUTSIDEBLK; /* block is empty */
- else
+ if (dctx->uncomplen != (nlen ^ 0xFFFF)) {
+ error = DEFLATE_ERR_UNCOMP_HDR;
+ goto finished;
+ }
+ if (dctx->uncomplen == 0) {/* block is empty */
+ if (dctx->lastblock)
+ dctx->state = END;
+ else
+ dctx->state = OUTSIDEBLK;
+ } else
dctx->state = UNCOMP_DATA;
break;
case UNCOMP_DATA:
#endif
emit_char(dctx, dctx->bits & 0xFF);
EATBITS(8);
- if (--dctx->uncomplen == 0)
- dctx->state = OUTSIDEBLK; /* end of uncompressed block */
+ if (--dctx->uncomplen == 0) { /* end of uncompressed block */
+ if (dctx->lastblock)
+ dctx->state = END;
+ else
+ dctx->state = OUTSIDEBLK;
+ }
break;
case END:
/*