Fixes in the LoadPluginSet() function:
- the naming scheme for backend libraries is "libTYPE.so", where TYPE
is the backend type (e.g. for tpk it should load libtpk.so)
- elements of the global plugin_set_list array should be allocated
every time a new backend library is loaded as this behaviour is
expected by the backend api: pkg_plugin_on_load() function expects
its input parameter to be an already allocated memory area, otherwise
it returns -1 and the LoadPluginSet() reports a failure:
extern "C" int pkg_plugin_on_load(pkg_plugin_set* set) {
if (set == nullptr)
return -1;
set->plugin_on_unload = PluginOnUnload;
...
}
Change-Id: I603030871a28f050f1d87ce572c102c3d0b5dc90
}
}
- std::string lib_path = kPkgLibPath + type + ".so";
+ std::string lib_path = kPkgLibPath + std::string("lib") + type + ".so";
void* handle = dlopen(lib_path.c_str(), RTLD_LAZY);
if (!handle) {
_E("failed to load library %s", lib_path.c_str());
return nullptr;
}
+ plugin_set_list[i] = reinterpret_cast<pkg_plugin_set *>(calloc(1, sizeof(pkg_plugin_set)));
+ if (plugin_set_list[i] == NULL) {
+ _E("malloc of the plugin_set_list element is failed");
+ dlclose(handle);
+ return nullptr;
+ }
+
if (on_load(plugin_set_list[i]) != 0) {
_E("pkg_plugin_on_load failed");
free(plugin_set_list[i]);