spotify/cocoalibspotify — Issue #21: Memory Leak in SPURLExtensions
Author: koupoo
Created: 2011-10-31 02:30:25+00:00
State: open

In the file SPURLExtensions.m，there is method showed below:
-(sp_linktype)spotifyLinkType {

sp_link *link = [self createSpotifyLink];
if (link != NULL) {
return sp_link_type(link);
sp_link_release(link);
}
return SP_LINKTYPE_INVALID;
}

When the link is not NULL, the method return before the link is released.

So I try to modify the method like this:
-(sp_linktype)spotifyLinkType {

sp_link *link = [self createSpotifyLink];
if (link != NULL) {
sp_linktype type = sp_link_type(link);
sp_link_release(link);
return type;
}
return SP_LINKTYPE_INVALID;
}

But after modify, run my app, it crashed during SPTrack's initialization:

-(id)initWithTrackStruct:(sp_track *)tr inSession:(SPSession *)aSession{
if ((self = [super init])) {
session = aSession;
track = tr;
sp_track_add_ref(track); //my app crashed here:Program received signal: "EXC_BAD_ACCESS"

if (!sp_track_is_loaded(track)) {
[self performSelector:@selector(checkLoaded)
withObject:nil
afterDelay:kCheckLoadedDuration];
} else {
[self loadTrackData];
}
}
return self;

}