Browse Source

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

Signed-off-by: Rémi Denis-Courmont <remi@remlab.net>
pull/18/head
Jerome Forissier 13 years ago
committed by Rémi Denis-Courmont
parent
commit
c88cf59b9d
  1. 12
      lib/error.c

12
lib/error.c

@ -33,11 +33,17 @@ static vlc_threadvar_t context;
static vlc_mutex_t lock = VLC_STATIC_MUTEX; static vlc_mutex_t lock = VLC_STATIC_MUTEX;
static uintptr_t refs = 0; static uintptr_t refs = 0;
static void free_msg (void *msg)
{
if (msg != oom)
free (msg);
}
void libvlc_threads_init (void) void libvlc_threads_init (void)
{ {
vlc_mutex_lock (&lock); vlc_mutex_lock (&lock);
if (refs++ == 0) if (refs++ == 0)
vlc_threadvar_create (&context, free); vlc_threadvar_create (&context, free_msg);
vlc_mutex_unlock (&lock); vlc_mutex_unlock (&lock);
} }
@ -57,9 +63,7 @@ static char *get_error (void)
static void free_error (void) static void free_error (void)
{ {
char *msg = get_error (); free_msg (get_error ());
if (msg != oom)
free (msg);
} }
/** /**

Loading…
Cancel
Save