aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-08-14 11:51:42 +0200
committerMax Kellermann <max@duempel.org>2009-08-14 11:51:42 +0200
commit1c4f407a6db4c4795bbbc354f5cf311762fb8e33 (patch)
treeb405a5b333063966931411f170ffd6471bbaf6c6 /src
parente44f31391234607ce0e95d69903142e71d61c813 (diff)
downloadmpd-1c4f407a6db4c4795bbbc354f5cf311762fb8e33.tar.gz
mpd-1c4f407a6db4c4795bbbc354f5cf311762fb8e33.tar.xz
mpd-1c4f407a6db4c4795bbbc354f5cf311762fb8e33.zip
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.
Diffstat (limited to '')
-rw-r--r--src/decoder/_flac_common.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/decoder/_flac_common.c b/src/decoder/_flac_common.c
index ae7d039ce..e096750f3 100644
--- a/src/decoder/_flac_common.c
+++ b/src/decoder/_flac_common.c
@@ -377,13 +377,15 @@ char*
flac_cue_track( const char* pathname,
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);
-
- if (cs == NULL)
+ success = FLAC__metadata_get_cuesheet(pathname, &cs);
+ if (!success)
return NULL;
+ assert(cs != NULL);
+
if (cs->data.cue_sheet.num_tracks <= 1)
{
FLAC__metadata_object_delete(cs);