Commit 318c24cb authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont
Browse files

modules: fix race in module_Map()

parent 678a61d1
......@@ -639,23 +639,31 @@ static module_t *module_InitStatic (vlc_plugin_cb entry)
*/
int module_Map (vlc_object_t *obj, module_t *module)
{
static vlc_mutex_t lock = VLC_STATIC_MUTEX;
if (module->parent != NULL)
module = module->parent;
#warning FIXME: race condition!
if (module->b_loaded)
return 0;
assert (module->psz_filename != NULL);
vlc_mutex_lock(&lock);
if (!module->b_loaded)
{
module_t *uncache;
assert (module->psz_filename != NULL);
#ifdef HAVE_DYNAMIC_PLUGINS
module_t *uncache = module_InitDynamic (obj, module->psz_filename, false);
if (uncache != NULL)
{
CacheMerge (obj, module, uncache);
vlc_module_destroy (uncache);
return 0;
}
uncache = module_InitDynamic (obj, module->psz_filename, false);
if (uncache != NULL)
{
CacheMerge (obj, module, uncache);
vlc_module_destroy (uncache);
}
else
#endif
msg_Err (obj, "corrupt module: %s", module->psz_filename);
return -1;
{
msg_Err (obj, "corrupt module: %s", module->psz_filename);
module = NULL;
}
}
vlc_mutex_unlock(&lock);
return -(module == NULL);
}
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