[vlc-commits] meta_reader: fix taglib leak on static method

Francois Cartegnie git at videolan.org
Fri Feb 19 16:09:42 CET 2016


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Feb 19 15:47:36 2016 +0100| [ee7e7136f7976de49d0ea2f944b1ee2a24b49051] | committer: Francois Cartegnie

meta_reader: fix taglib leak on static method

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ee7e7136f7976de49d0ea2f944b1ee2a24b49051
---

 modules/meta_engine/taglib.cpp |   15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/modules/meta_engine/taglib.cpp b/modules/meta_engine/taglib.cpp
index b6df4f9..4a1a15b 100644
--- a/modules/meta_engine/taglib.cpp
+++ b/modules/meta_engine/taglib.cpp
@@ -129,6 +129,12 @@ File *VLCTagLib::ExtResolver<T>::createFile(FileName fileName, bool, AudioProper
     return 0;
 }
 
+#if TAGLIB_VERSION >= TAGLIB_SYNCDECODE_FIXED_VERSION
+static VLCTagLib::ExtResolver<MPEG::File> aacresolver(".aac");
+#endif
+static VLCTagLib::ExtResolver<MP4::File> m4vresolver(".m4v");
+static bool b_extensions_registered = false;
+
 // taglib is not thread safe
 static vlc_mutex_t taglib_lock = VLC_STATIC_MUTEX;
 
@@ -718,11 +724,14 @@ static int ReadMeta( vlc_object_t* p_this)
     if( psz_path == NULL )
         return VLC_EGENERIC;
 
+    if( !b_extensions_registered )
+    {
 #if TAGLIB_VERSION >= TAGLIB_SYNCDECODE_FIXED_VERSION
-    FileRef::addFileTypeResolver( new VLCTagLib::ExtResolver<MPEG::File>(".aac") );
+        FileRef::addFileTypeResolver( &aacresolver );
 #endif
-
-    FileRef::addFileTypeResolver( new VLCTagLib::ExtResolver<MP4::File>(".m4v") );
+        FileRef::addFileTypeResolver( &m4vresolver );
+        b_extensions_registered = true;
+    }
 
 #if defined(_WIN32)
     wchar_t *wpath = ToWide( psz_path );



More information about the vlc-commits mailing list