]> git.sesse.net Git - vlc/commitdiff
libvlc: fix possible free() of static const char[]
authorJerome Forissier <jerome@taodyne.com>
Thu, 27 Feb 2014 15:53:24 +0000 (16:53 +0100)
committerRémi Denis-Courmont <remi@remlab.net>
Thu, 27 Feb 2014 16:34:20 +0000 (18:34 +0200)
Signed-off-by: Rémi Denis-Courmont <remi@remlab.net>
lib/error.c

index f942f4d0e28db220b3e9416a85b09b0e23f798af..45397a66c99088c7573d7fdc90a3e73ea014bdb9 100644 (file)
@@ -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 ());
 }
 
 /**