[sound-juicer] Fix a memory leak



commit 420c4934e8a5b3a769c4a3d6633c3aad781a27b9
Author: Phillip Wood <phillip wood dunelm org uk>
Date:   Wed Sep 21 19:13:32 2016 +0100

    Fix a memory leak
    
    The GET macro already calls strdup() on the title so we don’t want to
    copy it again. Found with asan.

 libjuicer/sj-metadata-musicbrainz5.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/libjuicer/sj-metadata-musicbrainz5.c b/libjuicer/sj-metadata-musicbrainz5.c
index a8175dd..c96dfb8 100644
--- a/libjuicer/sj-metadata-musicbrainz5.c
+++ b/libjuicer/sj-metadata-musicbrainz5.c
@@ -899,8 +899,8 @@ fill_tracks_from_medium (SjMetadataMusicbrainz5  *self,
 
     recording = mb5_track_get_recording (mbt);
     /*
-     * title points to a string on the stack so set it to NULL to
-     * prevent the GET macro from trying to free it
+     * title is owned by the last track so set it to NULL to prevent
+     * the GET macro from freeing it
      */
     title = NULL;
     GET (title, mb5_track_get_title, mbt);
@@ -913,6 +913,7 @@ fill_tracks_from_medium (SjMetadataMusicbrainz5  *self,
      */
     if (skip_data_tracks) {
       if (g_strcmp0 (title, "[data track]") == 0) {
+        g_free (title);
         continue;
       } else {
         skip_data_tracks = FALSE;
@@ -921,7 +922,7 @@ fill_tracks_from_medium (SjMetadataMusicbrainz5  *self,
     }
 
     track = g_new0 (TrackDetails, 1);
-    track->title = g_strdup (title);
+    track->title = title;
     track->album = album;
 
     track->number = mb5_track_get_position (mbt) - track_offset;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]