Fixed memory leaks.
parent
4dacefe989
commit
a49cd40952
|
@ -115,6 +115,10 @@ int corlett_decode(uint8 *input, uint32 input_len, uint8 **output, uint64 *size,
|
||||||
|
|
||||||
// Decompress data if any
|
// Decompress data if any
|
||||||
decomp_dat = malloc(DECOMP_MAX_SIZE);
|
decomp_dat = malloc(DECOMP_MAX_SIZE);
|
||||||
|
if (NULL == decomp_dat) {
|
||||||
|
return AO_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
decomp_length = DECOMP_MAX_SIZE;
|
decomp_length = DECOMP_MAX_SIZE;
|
||||||
if (uncompress(decomp_dat, &decomp_length, (unsigned char *)&buf[4+(res_area/4)], comp_length) != Z_OK)
|
if (uncompress(decomp_dat, &decomp_length, (unsigned char *)&buf[4+(res_area/4)], comp_length) != Z_OK)
|
||||||
{
|
{
|
||||||
|
|
|
@ -254,11 +254,12 @@ int32 psf_start(uint8 *buffer, uint32 length)
|
||||||
|
|
||||||
// Dispose the corlett structure for the lib - we don't use it
|
// Dispose the corlett structure for the lib - we don't use it
|
||||||
free(lib);
|
free(lib);
|
||||||
|
free(alib_decoded);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(file);
|
free(file);
|
||||||
// free(lib_decoded);
|
free(lib_decoded);
|
||||||
|
|
||||||
// Finally, set psfby tag
|
// Finally, set psfby tag
|
||||||
strcpy(psfby, "n/a");
|
strcpy(psfby, "n/a");
|
||||||
|
|
|
@ -507,6 +507,8 @@ int32 psf2_start(uint8 *buffer, uint32 length)
|
||||||
return AO_FAIL;
|
return AO_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(lib_raw_file);
|
||||||
|
|
||||||
#if DEBUG_LOADER
|
#if DEBUG_LOADER
|
||||||
printf("Lib FS section: size %x bytes\n", lib->res_size);
|
printf("Lib FS section: size %x bytes\n", lib->res_size);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -209,16 +209,14 @@ int ao_get_lib(char *fn, uint8 **buf, uint64 *length)
|
||||||
{
|
{
|
||||||
NSLog(@"ERROR: File is unknown, signature bytes are %02x %02x %02x %02x\n", buffer[0], buffer[1], buffer[2], buffer[3]);
|
NSLog(@"ERROR: File is unknown, signature bytes are %02x %02x %02x %02x\n", buffer[0], buffer[1], buffer[2], buffer[3]);
|
||||||
|
|
||||||
free(buffer);
|
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ((*types[type].start)(buffer, size) != AO_SUCCESS)
|
if ((*types[type].start)(buffer, size) != AO_SUCCESS)
|
||||||
{
|
{
|
||||||
free(buffer);
|
|
||||||
NSLog(@"ERROR: Engine rejected file!\n");
|
NSLog(@"ERROR: Engine rejected file!\n");
|
||||||
|
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +233,9 @@ int ao_get_lib(char *fn, uint8 **buf, uint64 *length)
|
||||||
[globalLock lock];
|
[globalLock lock];
|
||||||
|
|
||||||
BOOL ret = [self openUnderLock:source];
|
BOOL ret = [self openUnderLock:source];
|
||||||
|
if (!ret) {
|
||||||
|
[self close];
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,7 +257,10 @@ int ao_get_lib(char *fn, uint8 **buf, uint64 *length)
|
||||||
- (void)closeUnderLock
|
- (void)closeUnderLock
|
||||||
{
|
{
|
||||||
(*types[type ].stop)();
|
(*types[type ].stop)();
|
||||||
free(buffer);
|
if (NULL != buffer) {
|
||||||
|
free(buffer);
|
||||||
|
buffer = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
[currentSource release];
|
[currentSource release];
|
||||||
currentSource = nil;
|
currentSource = nil;
|
||||||
|
@ -307,6 +310,7 @@ int ao_get_lib(char *fn, uint8 **buf, uint64 *length)
|
||||||
NSDictionary *metadata = [decoder metadata];
|
NSDictionary *metadata = [decoder metadata];
|
||||||
|
|
||||||
[decoder closeUnderLock];
|
[decoder closeUnderLock];
|
||||||
|
[decoder release];
|
||||||
|
|
||||||
[globalLock unlock];
|
[globalLock unlock];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue