Commit 03b701d5 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

var_AcquireMutex: enforce constant mutex name

parent e516ddb1
......@@ -131,6 +131,23 @@ VLC_EXPORT( int, __var_Get, ( vlc_object_t *, const char *, vlc_value_t * ) );
VLC_EXPORT( int, __var_Command, ( vlc_object_t *, const char *, const char *, const char *, char ** ) );
VLC_EXPORT( vlc_mutex_t *, var_AcquireMutex, ( const char * ) );
#ifdef __GNUC__
static
__attribute__((unused))
__attribute__((noinline))
__attribute__((error("variable mutex name leaks memory at run-time")))
const char *nonconst_mutex_name( const char *str )
{
return str;
}
# define check_named_mutex( m ) \
(__builtin_constant_p(m) ? m : nonconst_mutex_name(m))
#else
# define check_named_mutex( m ) (m)
#endif
#define var_AcquireMutex( n ) var_AcquireMutex(check_named_mutex(n))
/**
* __var_Create() with automatic casting.
......
......@@ -848,6 +848,7 @@ int __var_Get( vlc_object_t *p_this, const char *psz_name, vlc_value_t *p_val )
}
#undef var_AcquireMutex
/**
* Finds a process-wide mutex, creates it if needed, and locks it.
* Unlock with vlc_mutex_unlock().
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment