Bug 141682 - Taglib memory leaks found with Valgrind
Summary: Taglib memory leaks found with Valgrind
Status: RESOLVED FIXED
Alias: None
Product: taglib
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Scott Wheeler
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-02-14 14:28 UTC by Xavier Duret
Modified: 2007-04-01 22:27 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Memory leaks fix (1.46 KB, patch)
2007-02-14 14:29 UTC, Xavier Duret
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Xavier Duret 2007-02-14 14:28:40 UTC
Version:           svn 633141 (using KDE Devel)
Installed from:    Compiled sources

I ran valgrind on taglib in subversion. There are 2 importants leaks plus 2 less important leaks.
The importants leaks are:
- failure to delete the APETag in mpegfile.
- failure to delete the private object of UniqueFileIdentifierFrame.

There are less important leaks related to not freeing the factory objects used by taglib.
Comment 1 Xavier Duret 2007-02-14 14:29:16 UTC
Created attachment 19688 [details]
Memory leaks fix

Trivial patch.
Comment 2 Sander Jansen 2007-02-16 05:36:51 UTC
In libtag_c (1.4.0) I'm also getting the following alloc / free mismatch

==18834== 1688 errors in context 19 of 19:
==18834== Thread 6:
==18834== Mismatched free() / delete / delete []
==18834==    at 0x4020937: operator delete[](void*) (in /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
==18834==    by 0x48D9CDE: taglib_tag_free_strings (in /usr/lib/libtag_c.so.0.0.0)

coming from:
==18834==    at 0x4021384: malloc (in /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
==18834==    by 0x4A5C01F: strdup (in /lib/libc-2.5.so)
==18834==    by 0x48D9B69: taglib_tag_artist (in /usr/lib/libtag_c.so.0.0.0)


Almost looks like strings allocated with strdup are getting freeed by delete []
Comment 3 Scott Wheeler 2007-02-16 15:15:36 UTC
The C bindings issue has already been fixed in SVN.
Comment 4 Scott Wheeler 2007-02-16 15:29:45 UTC
SVN commit 634161 by wheeler:

Delete d-pointer.

CCBUG:141682


 M  +5 -0      uniquefileidentifierframe.cpp  
 M  +5 -0      uniquefileidentifierframe.h  


--- trunk/kdesupport/taglib/taglib/mpeg/id3v2/frames/uniquefileidentifierframe.cpp #634160:634161
@@ -52,6 +52,11 @@
   d->identifier = id;
 }
 
+UniqueFileIdentifierFrame::~UniqueFileIdentifierFrame()
+{
+	delete d;
+}
+
 String UniqueFileIdentifierFrame::owner() const
 {
     return d->owner;
--- trunk/kdesupport/taglib/taglib/mpeg/id3v2/frames/uniquefileidentifierframe.h #634160:634161
@@ -52,6 +52,11 @@
        */
       UniqueFileIdentifierFrame(const String &owner, const ByteVector &id);
 
+			/*!
+			 * Destroys the frame.
+			 */
+			~UniqueFileIdentifierFrame();
+
       /*!
        * Returns the owner for the frame; essentially this is the key for
        * determining which identification scheme this key belongs to.  This
Comment 5 Scott Wheeler 2007-04-01 22:27:46 UTC
SVN commit 648984 by wheeler:

Delete APE tag.

BUG:141682


 M  +1 -0      mpegfile.cpp  


--- trunk/kdesupport/taglib/taglib/mpeg/mpegfile.cpp #648983:648984
@@ -188,6 +188,7 @@
   ~FilePrivate() {
     delete ID3v2Tag;
     delete ID3v1Tag;
+		delete APETag;
     delete tag;
     delete properties;
   }