Very big and ugly memory leaks
Allan Sandfeld Jensen
kde at carewolf.com
Sun Apr 3 18:49:25 CEST 2005
On Sunday 03 April 2005 14:45, Benoit Amiaux wrote:
> Hello, two evil gremlins were hidden inside taglib. I spent a lot of
> time chasing them in my code until I realized that the following piece
> of code was leaking:
>
> TagLib::MPC:File foo("blah.mpc");
> delete foo;
>
> It looks like as if nobody tested ape tag reading in musepack files :(
>
I tested it allright. I just didn't valgrind it :(
> Anyway, here is a patch for the two of them. IMO it's a big enough bug
> to trigger a new minor taglib release as any file with APE tags or any
> musepack file will leak a lots of memory.
>
> --- apeitem.cpp 2004-11-06 18:27:20.000000000 +0100
> +++ apeitem.cpp 2005-04-03 14:25:39.336529936 +0200
> @@ -62,6 +62,11 @@
> d = new ItemPrivate(*item.d);
> }
>
> +APE::Item::~Item()
> +{
> + delete d;
> +}
> +
> Item &APE::Item::operator=(const Item &item)
> {
> delete d;
>
> --- mpcfile.cpp 2004-09-09 00:42:29.000000000 +0200
> +++ mpcfile.cpp 2005-04-03 14:25:16.253039160 +0200
> @@ -53,8 +53,9 @@
>
> ~FilePrivate()
> {
> - delete ID3v1Tag;
> + delete tag;
> delete properties;
> + delete ID3v2Header;
> }
>
Nice catch. There is however a problem with double-deletion since tag might be
ID3v1Tag, and you forgot APETag which wheeler added.
Thanks
`Allan
More information about the taglib-devel
mailing list