]> granicus.if.org Git - taglib/commitdiff
Fix various memleaks in the tests
authorUwe L. Korn <uwelk@xhochy.com>
Sun, 14 Sep 2014 17:03:27 +0000 (18:03 +0100)
committerUwe L. Korn <uwelk@xhochy.com>
Sun, 14 Sep 2014 17:03:27 +0000 (18:03 +0100)
tests/test_aiff.cpp
tests/test_fileref.cpp
tests/test_flac.cpp
tests/test_id3v2.cpp
tests/test_mp4.cpp
tests/test_riff.cpp
tests/utils.h

index df1c5ac123f592e1a9259a97cc9b9f4d3cace1d7..00a120889c9062b89f355dbc35987eb1645da6e6 100644 (file)
@@ -24,6 +24,7 @@ public:
 
     RIFF::AIFF::File *f = new RIFF::AIFF::File(filename.c_str());
     CPPUNIT_ASSERT_EQUAL(705, f->audioProperties()->bitrate());
+    delete f;
   }
 
 };
index 197a9213038323fae8075ccc3b98d413378ce6c3..f13eafaaf5744ebbc1bf00257a3806da2b91e5a9 100644 (file)
@@ -136,6 +136,7 @@ public:
       FileRef *f = new FileRef(TEST_FILE_PATH_C("empty_flac.oga"));
       CPPUNIT_ASSERT(dynamic_cast<Ogg::Vorbis::File *>(f->file()) == NULL);
       CPPUNIT_ASSERT(dynamic_cast<Ogg::FLAC::File *>(f->file()) != NULL);
+      delete f;
   }
 
   void testOGA_Vorbis()
@@ -143,6 +144,7 @@ public:
       FileRef *f = new FileRef(TEST_FILE_PATH_C("empty_vorbis.oga"));
       CPPUNIT_ASSERT(dynamic_cast<Ogg::Vorbis::File *>(f->file()) != NULL);
       CPPUNIT_ASSERT(dynamic_cast<Ogg::FLAC::File *>(f->file()) == NULL);
+      delete f;
   }
 
   void testAPE()
index 22bbc854d4251b79d10ffdfee67af0c71e6eb935..f99a679a835c352ffe054b1b45f8d86918158eff 100644 (file)
@@ -69,6 +69,8 @@ public:
     CPPUNIT_ASSERT_EQUAL(String("image/png"), pic->mimeType());
     CPPUNIT_ASSERT_EQUAL(String("A pixel."), pic->description());
     CPPUNIT_ASSERT_EQUAL(TagLib::uint(150), pic->data().size());
+
+    delete f;
   }
 
   void testAddPicture()
index a77e46af41acef1be084a3d11078417c8fa420cc..1f080a1a0724ba2a90f321ee9426a3f38995d1aa 100644 (file)
@@ -207,6 +207,8 @@ public:
     CPPUNIT_ASSERT_EQUAL(String("image/jpeg"), frame->mimeType());
     CPPUNIT_ASSERT_EQUAL(ID3v2::AttachedPictureFrame::FileIcon, frame->type());
     CPPUNIT_ASSERT_EQUAL(String("d"), frame->description());
+
+    delete frame;
   }
 
   void testDontRender22()
index 9b90eed3613d896fb1e12fd23f112aed9100194e..7e25f9968383107b0e3341f4768c64ce8a42b843 100644 (file)
@@ -142,6 +142,7 @@ public:
     CPPUNIT_ASSERT_EQUAL(String("82,164"), f->tag()->itemListMap()["----:com.apple.iTunes:replaygain_track_minmax"].toStringList()[0]);
     CPPUNIT_ASSERT_EQUAL(String("Pearl Jam"), f->tag()->artist());
     CPPUNIT_ASSERT_EQUAL(String("foo"), f->tag()->comment());
+    delete f;
   }
 
   void test64BitAtom()
@@ -158,6 +159,7 @@ public:
 
     f->tag()->itemListMap()["pgap"] = true;
     f->save();
+    delete atoms;
     delete f;
 
     f = new MP4::File(filename.c_str());
@@ -168,6 +170,7 @@ public:
     moov = atoms->atoms[0];
     // original size + 'pgap' size + padding
     CPPUNIT_ASSERT_EQUAL(long(77 + 25 + 974), moov->length);
+    delete atoms;
     delete f;
   }
 
index 9b07a7ce16aba54c291eee1a484d065effe5777b..19bff169c0003e4e1705f367feb283b565333d30 100644 (file)
@@ -86,6 +86,8 @@ public:
 
     CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f->chunkName(2));
     CPPUNIT_ASSERT_EQUAL(ByteVector("foo"), f->chunkData(2));
+
+    delete f;
   }
 
   void testLastChunkAtEvenPosition()
index 5f2f9814a044234a03484cfac2d2b2af95066d61..dfe6c4c311b8dc2b285426333d73cdbd9f36984f 100644 (file)
@@ -11,6 +11,7 @@
 #include <sys/stat.h>
 #endif
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <string>
 #include <fstream>
@@ -26,7 +27,9 @@ inline string testFilePath(const string &filename)
 
 inline string copyFile(const string &filename, const string &ext)
 {
-  string newname = string(tempnam(NULL, NULL)) + ext;
+  char *newname_c = tempnam(NULL, NULL);
+  string newname = string(newname_c) + ext;
+  free(newname_c);
   string oldname = testFilePath(filename) + ext;
 #ifdef _WIN32
   CopyFileA(oldname.c_str(), newname.c_str(), FALSE);