From: Pierre d'Herbemont Date: Sun, 24 Jan 2010 10:46:00 +0000 (+0100) Subject: macosx/framework: Fix a bunch of leaks in -[VLCMediaPlayer videoSubTitles]. X-Git-Tag: 1.1.0-ff~977 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=4e0ec1d2c8b66b6c2bf10cffc315f504f3238679;p=vlc macosx/framework: Fix a bunch of leaks in -[VLCMediaPlayer videoSubTitles]. --- diff --git a/projects/macosx/framework/Sources/VLCMediaPlayer.m b/projects/macosx/framework/Sources/VLCMediaPlayer.m index 51b535eb8b..0c48bb59ea 100644 --- a/projects/macosx/framework/Sources/VLCMediaPlayer.m +++ b/projects/macosx/framework/Sources/VLCMediaPlayer.m @@ -316,18 +316,14 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s - (NSArray *)videoSubTitles { - libvlc_exception_t ex; - libvlc_exception_init( &ex ); - NSInteger count = libvlc_video_get_spu_count( instance, &ex ); - catch_exception( &ex ); - - libvlc_track_description_t *tracks = libvlc_video_get_spu_description( instance, &ex ); + libvlc_track_description_t *currentTrack = libvlc_video_get_spu_description( instance, &ex ); NSMutableArray *tempArray = [NSMutableArray array]; - NSInteger i; - for (i = 0; i < count; i++) - { - [tempArray addObject:[NSString stringWithUTF8String: tracks->psz_name]]; - tracks = tracks->p_next; + while (currentTrack) { + [tempArray addObject:[NSString stringWithUTF8String:currentTrack->psz_name]]; + free(currentTrack->psz_name); + libvlc_track_description_t *tofree = currentTrack; + currentTrack = currentTrack->p_next; + free(tofree); } return [NSArray arrayWithArray: tempArray]; }