/****************************************************************
* QTMupdatemodel (internal)
*/
-void QTMupdatemodel(struct QTMmodel *model, int sym) {
+static void QTMupdatemodel(struct QTMmodel *model, int sym) {
struct QTMmodelsym temp;
int i, j;
* OK: 0
* error: 1
*/
-int make_decode_table(cab_ULONG nsyms, cab_ULONG nbits, const cab_UBYTE *length, cab_UWORD *table) {
+static int make_decode_table(cab_ULONG nsyms, cab_ULONG nbits,
+ const cab_UBYTE *length, cab_UWORD *table) {
register cab_UWORD sym;
register cab_ULONG leaf;
register cab_UBYTE bit_num = 1;
/*************************************************************************
* checksum (internal)
*/
-cab_ULONG checksum(const cab_UBYTE *data, cab_UWORD bytes, cab_ULONG csum) {
+static cab_ULONG checksum(const cab_UBYTE *data, cab_UWORD bytes, cab_ULONG csum) {
int len;
cab_ULONG ul = 0;
l[h] = j; /* set table size in stack */
/* allocate and link in new table */
- if (!(q = (struct Ziphuft *) PFDI_ALLOC(CAB(hfdi), (z + 1)*sizeof(struct Ziphuft))))
+ if (!(q = PFDI_ALLOC(CAB(hfdi), (z + 1)*sizeof(struct Ziphuft))))
{
if(h)
fdi_Ziphuft_free(CAB(hfdi), ZIP(u)[0]);
if (cab->mii.folder_resv > 0)
PFDI_SEEK(CAB(hfdi), cab->cabhf, cab->mii.folder_resv, SEEK_CUR);
-
- fol = (struct fdi_folder *) PFDI_ALLOC(CAB(hfdi), sizeof(struct fdi_folder));
+
+ fol = PFDI_ALLOC(CAB(hfdi), sizeof(struct fdi_folder));
if (!fol) {
ERR("out of memory!\n");
return DECR_NOMEMORY;
for (i = 0; i < fdici.cFiles; i++) {
if (PFDI_READ(CAB(hfdi), cab->cabhf, buf2, cffile_SIZEOF) != cffile_SIZEOF)
return DECR_INPUT;
-
- file = (struct fdi_file *) PFDI_ALLOC(CAB(hfdi), sizeof(struct fdi_file));
+
+ file = PFDI_ALLOC(CAB(hfdi), sizeof(struct fdi_file));
if (!file) {
ERR("out of memory!\n");
return DECR_NOMEMORY;
return DECR_OK;
}
-static void free_decompression_temps(HFDI hfdi, struct fdi_folder *fol,
+static void free_decompression_temps(HFDI hfdi, const struct fdi_folder *fol,
fdi_decomp_state *decomp_state)
{
switch (fol->comp_type & cffoldCOMPTYPE_MASK) {
}
}
-static void free_decompression_mem(HFDI hfdi, struct fdi_folder *fol,
+static void free_decompression_mem(HFDI hfdi,
fdi_decomp_state *decomp_state, struct fdi_file *file)
{
+ struct fdi_folder *fol;
while (decomp_state) {
fdi_decomp_state *prev_fds;
/* slight overestimation here to save CPU cycles in the developer's brain */
if ((pathlen + filenamelen + 3) > MAX_PATH) {
ERR("MAX_PATH exceeded.\n");
+ PFDI_FREE(hfdi, decomp_state);
PFDI_INT(hfdi)->perf->erfOper = FDIERROR_CABINET_NOT_FOUND;
PFDI_INT(hfdi)->perf->erfType = ERROR_FILE_NOT_FOUND;
PFDI_INT(hfdi)->perf->fError = TRUE;
/* get a handle to the cabfile */
cabhf = PFDI_OPEN(hfdi, fullpath, _O_RDONLY|_O_BINARY, _S_IREAD | _S_IWRITE);
if (cabhf == -1) {
+ PFDI_FREE(hfdi, decomp_state);
PFDI_INT(hfdi)->perf->erfOper = FDIERROR_CABINET_NOT_FOUND;
PFDI_INT(hfdi)->perf->fError = TRUE;
SetLastError(ERROR_FILE_NOT_FOUND);
if (cabhf == 0) {
ERR("PFDI_OPEN returned zero for %s.\n", fullpath);
+ PFDI_FREE(hfdi, decomp_state);
PFDI_INT(hfdi)->perf->erfOper = FDIERROR_CABINET_NOT_FOUND;
PFDI_INT(hfdi)->perf->erfType = ERROR_FILE_NOT_FOUND;
PFDI_INT(hfdi)->perf->fError = TRUE;
/* check if it's really a cabfile. Note that this doesn't implement the bug */
if (!FDI_read_entries(hfdi, cabhf, &fdici, &(CAB(mii)))) {
ERR("FDIIsCabinet failed.\n");
+ PFDI_FREE(hfdi, decomp_state);
PFDI_CLOSE(hfdi, cabhf);
return FALSE;
}
if (CAB(mii).folder_resv > 0)
PFDI_SEEK(hfdi, cabhf, CAB(mii).folder_resv, SEEK_CUR);
- fol = (struct fdi_folder *) PFDI_ALLOC(hfdi, sizeof(struct fdi_folder));
+ fol = PFDI_ALLOC(hfdi, sizeof(struct fdi_folder));
if (!fol) {
ERR("out of memory!\n");
PFDI_INT(hfdi)->perf->erfOper = FDIERROR_ALLOC_FAIL;
goto bail_and_fail;
}
- file = (struct fdi_file *) PFDI_ALLOC(hfdi, sizeof(struct fdi_file));
+ file = PFDI_ALLOC(hfdi, sizeof(struct fdi_file));
if (!file) {
ERR("out of memory!\n");
PFDI_INT(hfdi)->perf->erfOper = FDIERROR_ALLOC_FAIL;
}
free_decompression_temps(hfdi, fol, decomp_state);
- free_decompression_mem(hfdi, fol, decomp_state, file);
+ free_decompression_mem(hfdi, decomp_state, file);
return TRUE;
bail_and_fail: /* here we free ram before error returns */
- free_decompression_temps(hfdi, fol, decomp_state);
+ if (fol) free_decompression_temps(hfdi, fol, decomp_state);
if (filehf) PFDI_CLOSE(hfdi, filehf);
- free_decompression_mem(hfdi, fol, decomp_state, file);
+ free_decompression_mem(hfdi, decomp_state, file);
return FALSE;
}