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