MT#59962 DSMChartReader: close `h_dl` if import failed

If import of the DSM module fails, close previously
allocated handler for dynamic linking.

Fixes:

    CID 542305: (#1 of 1): Resource leak (RESOURCE_LEAK)
    13. leaked_storage: Variable h_dl going out of scope leaks the storage it points to.

Change-Id: I426188a2d819c320862ad7de64a01e5ad08e3725
master
Donat Zenichev 2 months ago
parent 3cea2a63ca
commit 5faf948b86

@ -261,13 +261,14 @@ bool DSMChartReader::importModule(const string& mod_cmd, const string& mod_path)
SCFactoryCreate fc = NULL;
if ((fc = (SCFactoryCreate)dlsym(h_dl,SC_FACTORY_EXPORT_STR)) == NULL) {
ERROR("invalid SC module '%s' (SC_EXPORT missing?)\n", fname.c_str());
dlclose(h_dl);
return false;
}
DSMModule* mod = (DSMModule*)fc();
if (!mod) {
ERROR("module '%s' did not return functions.\n",
fname.c_str());
ERROR("module '%s' did not return functions.\n", fname.c_str());
dlclose(h_dl);
return false;
}

Loading…
Cancel
Save