decoder/flac: don't allocate cuesheet twice (memleak)
The function flac_cue_track() first calls FLAC__metadata_object_new(), then overwrites this pointer with FLAC__metadata_get_cuesheet(). This allocate two FLAC__StreamMetadata objects, but the first pointer is lost, and never freed.
This commit is contained in:
		
							
								
								
									
										1
									
								
								NEWS
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								NEWS
									
									
									
									
									
								
							| @@ -5,6 +5,7 @@ ver 0.15.2 (2009/??/??) | |||||||
| * decoders: | * decoders: | ||||||
|   - mad: skip ID3 frames when libid3tag is disabled |   - mad: skip ID3 frames when libid3tag is disabled | ||||||
|   - flac: parse all replaygain tags |   - flac: parse all replaygain tags | ||||||
|  |   - flac: don't allocate cuesheet twice (memleak) | ||||||
| * update: free empty path string (memleak) | * update: free empty path string (memleak) | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -377,13 +377,15 @@ char* | |||||||
| flac_cue_track(	const char* pathname, | flac_cue_track(	const char* pathname, | ||||||
| 		const unsigned int tnum) | 		const unsigned int tnum) | ||||||
| { | { | ||||||
| 	FLAC__StreamMetadata* cs = FLAC__metadata_object_new(FLAC__METADATA_TYPE_CUESHEET); | 	FLAC__bool success; | ||||||
|  | 	FLAC__StreamMetadata* cs; | ||||||
|  |  | ||||||
| 	FLAC__metadata_get_cuesheet(pathname, &cs); | 	success = FLAC__metadata_get_cuesheet(pathname, &cs); | ||||||
|  | 	if (!success) | ||||||
| 	if (cs == NULL) |  | ||||||
| 		return NULL; | 		return NULL; | ||||||
|  |  | ||||||
|  | 	assert(cs != NULL); | ||||||
|  |  | ||||||
| 	if (cs->data.cue_sheet.num_tracks <= 1) | 	if (cs->data.cue_sheet.num_tracks <= 1) | ||||||
| 	{ | 	{ | ||||||
| 		FLAC__metadata_object_delete(cs); | 		FLAC__metadata_object_delete(cs); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Max Kellermann
					Max Kellermann