Kaynağa Gözat

libobs: Free module if obs_module_load callback returns false

Currently if a module fails its load callback, it remains loaded and OBS
continues to call additional exports such as obs_module_post_load. This
goes against the documented behavior, which states that a module that
fails its load callback is unloaded.

This commit releases locale resources and frees the module's
information, preventing further callbacks from libobs. The module itself
(the DLL) is not yet unloaded from memory as os_dlclose is commented out
for causing unspecified issues - this should be revisited in the future.
Richard Stanway 3 yıl önce
ebeveyn
işleme
4cc419e3c9
1 değiştirilmiş dosya ile 12 ekleme ve 1 silme
  1. 12 1
      libobs/obs-module.c

+ 12 - 1
libobs/obs-module.c

@@ -291,7 +291,8 @@ static void load_all_callback(void *param, const struct obs_module_info *info)
 		return;
 	}
 
-	obs_init_module(module);
+	if (!obs_init_module(module))
+		free_module(module);
 
 	UNUSED_PARAMETER(param);
 }
@@ -499,6 +500,16 @@ void free_module(struct obs_module *mod)
 		/* os_dlclose(mod->module); */
 	}
 
+	for (obs_module_t *m = obs->first_module; !!m; m = m->next) {
+		if (m->next == mod) {
+			m->next = mod->next;
+			break;
+		}
+	}
+
+	if (obs->first_module == mod)
+		obs->first_module = mod->next;
+
 	bfree(mod->mod_name);
 	bfree(mod->bin_path);
 	bfree(mod->data_path);