Fix for double free with new code.

This commit is contained in:
Chris Moeller 2016-07-02 02:58:21 -07:00
parent 7bb722cdec
commit 592d6a6a30
2 changed files with 7 additions and 1 deletions

View file

@ -12,6 +12,7 @@
@interface HCDecoder : NSObject<CogDecoder,CogMetadataReader> { @interface HCDecoder : NSObject<CogDecoder,CogMetadataReader> {
id<CogSource> currentSource; id<CogSource> currentSource;
BOOL hintAdded;
NSString *currentUrl; NSString *currentUrl;
uint8_t *emulatorCore; uint8_t *emulatorCore;
void *emulatorExtra; void *emulatorExtra;

View file

@ -183,6 +183,7 @@ static psf_file_callbacks source_callbacks =
{ {
self = [super init]; self = [super init];
if (self) { if (self) {
hintAdded = NO;
type = 0; type = 0;
emulatorCore = NULL; emulatorCore = NULL;
emulatorExtra = NULL; emulatorExtra = NULL;
@ -1229,6 +1230,7 @@ static int usf_info(void * context, const char * name, const char * value)
currentUrl = [[[source url] absoluteString] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; currentUrl = [[[source url] absoluteString] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[psf_file_container instance] add_hint:currentUrl source:currentSource]; [[psf_file_container instance] add_hint:currentUrl source:currentSource];
hintAdded = YES;
type = psf_load( [currentUrl UTF8String], &source_callbacks, 0, 0, 0, psf_info_meta, &info, 0 ); type = psf_load( [currentUrl UTF8String], &source_callbacks, 0, 0, 0, psf_info_meta, &info, 0 );
@ -1478,7 +1480,10 @@ static int usf_info(void * context, const char * name, const char * value)
{ {
[self closeDecoder]; [self closeDecoder];
currentSource = nil; currentSource = nil;
[[psf_file_container instance] remove_hint:currentUrl]; if (hintAdded) {
[[psf_file_container instance] remove_hint:currentUrl];
hintAdded = NO;
}
currentUrl = nil; currentUrl = nil;
} }