[vlc-commits] libvlc: fix possible free() of static const char[]

Jerome Forissier git at videolan.org
Thu Feb 27 17:34:53 CET 2014


vlc/vlc-2.1 | branch: master | Jerome Forissier <jerome at taodyne.com> | Thu Feb 27 16:53:24 2014 +0100| [ee2540e70e963bba66482edf5022972234731c15] | committer: Rémi Denis-Courmont

libvlc: fix possible free() of static const char[]

Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>
(cherry picked from commit c88cf59b9da0d13559e0c63fb63a3fd7f1bd867a)

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

 lib/error.c |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/lib/error.c b/lib/error.c
index f942f4d..45397a6 100644
--- a/lib/error.c
+++ b/lib/error.c
@@ -33,11 +33,17 @@ static vlc_threadvar_t context;
 static vlc_mutex_t lock = VLC_STATIC_MUTEX;
 static uintptr_t refs = 0;
 
+static void free_msg (void *msg)
+{
+    if (msg != oom)
+        free (msg);
+}
+
 void libvlc_threads_init (void)
 {
     vlc_mutex_lock (&lock);
     if (refs++ == 0)
-        vlc_threadvar_create (&context, free);
+        vlc_threadvar_create (&context, free_msg);
     vlc_mutex_unlock (&lock);
 }
 
@@ -57,9 +63,7 @@ static char *get_error (void)
 
 static void free_error (void)
 {
-    char *msg = get_error ();
-    if (msg != oom)
-        free (msg);
+    free_msg (get_error ());
 }
 
 /**



More information about the vlc-commits mailing list