From 5faf948b8622d9ca8f6d92844a2b1f5cfcb937b9 Mon Sep 17 00:00:00 2001 From: Donat Zenichev Date: Fri, 25 Apr 2025 11:16:48 +0200 Subject: [PATCH] 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 --- apps/dsm/DSMChartReader.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/dsm/DSMChartReader.cpp b/apps/dsm/DSMChartReader.cpp index 4dd0c253..8c49eb80 100644 --- a/apps/dsm/DSMChartReader.cpp +++ b/apps/dsm/DSMChartReader.cpp @@ -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; }