unsigned char *data, int len, int compress)
{
struct LZ77InternalContext *st = ctx->ictx;
- int i, hash, distance, off, nmatch, matchlen, advance;
+ int i, distance, off, nmatch, matchlen, advance;
struct Match defermatch, matches[MAXMATCH];
int deferchr;
/*
* Hash the next few characters.
*/
- hash = lz77_hash(data);
+ int hash = lz77_hash(data);
/*
* Look the hash up in the corresponding hash chain and see
}
} else {
nmatch = 0;
- hash = INVALID;
}
if (nmatch > 0) {
goto finished;
if (code == -2)
goto decode_error;
+ if (code >= 30) /* dist symbols 30 and 31 are invalid */
+ goto decode_error;
dctx->state = GOTDISTSYM;
dctx->sym = code;
break;
sfree(outbuf);
} else {
fprintf(stderr, "decoding error\n");
+ fclose(fp);
return 1;
}
}