Fix crash if unable to load plugin.

This commit is contained in:
Jan Vidar Krey 2018-11-21 11:00:20 +01:00
parent 602f1b8843
commit 91b3de5fad

View File

@ -102,7 +102,6 @@ struct plugin_handle* plugin_load(const char* filename, const char* config, stru
int ret; int ret;
struct plugin_handle* handle = (struct plugin_handle*) hub_malloc_zero(sizeof(struct plugin_handle)); struct plugin_handle* handle = (struct plugin_handle*) hub_malloc_zero(sizeof(struct plugin_handle));
struct uhub_plugin* plugin = plugin_open(filename); struct uhub_plugin* plugin = plugin_open(filename);
struct plugin_hub_internals* internals = (struct plugin_hub_internals*) plugin->internals;
if (!plugin) if (!plugin)
return NULL; return NULL;
@ -118,6 +117,7 @@ struct plugin_handle* plugin_load(const char* filename, const char* config, stru
unregister_f = plugin_lookup_symbol(plugin, "plugin_unregister"); unregister_f = plugin_lookup_symbol(plugin, "plugin_unregister");
// register hub internals // register hub internals
struct plugin_hub_internals* internals = (struct plugin_hub_internals*) plugin->internals;
internals->unregister = unregister_f; internals->unregister = unregister_f;
internals->hub = hub; internals->hub = hub;
internals->callback_data = plugin_callback_data_create(); internals->callback_data = plugin_callback_data_create();