Prevent issue fix.
authorZbigniew Kostrzewa <z.kostrzewa@samsung.com>
Wed, 31 Jul 2013 07:34:46 +0000 (09:34 +0200)
committerZbigniew Kostrzewa <z.kostrzewa@samsung.com>
Mon, 5 Aug 2013 06:25:18 +0000 (08:25 +0200)
[Issue#] #17499
[Problem] Shared library opened with dlopen() but not closed.
[Cause] N/A
[Solution] Close the library with dlclose()
[SCMRequest] N/A
[Verification] Build repository.

Change-Id: Iea83e537f3fbff0682b2ca4b4b886088090b11e6

src/plugins-api-support/PluginRegistry.cpp

index adf6563..c4bc496 100644 (file)
@@ -31,7 +31,9 @@
 #include <algorithm>
 
 #include <dpl/log/log.h>
+#include <dpl/log/secure_log.h>
 #include <dpl/foreach.h>
+#include <dpl/scope_guard.h>
 
 namespace WrtPluginsApi {
 void PluginRegistry::AddPlugin(const std::string& libraryName,
@@ -87,6 +89,20 @@ void PluginRegistry::UnloadAll()
                 LogError("Error: " << (error != NULL ? error : "unknown"));
                 continue;
             }
+            DPL_SCOPE_EXIT(handle) {
+                if (dlclose(handle) != 0) {
+                    const char* error = dlerror();
+                    if (error != NULL)
+                    {
+                        std::string errstr{error};
+                        _E("%s", errstr.c_str());
+                    }
+                    else
+                    {
+                        _E("unknown error while closing plug-in library");
+                    }
+                }
+            };
 
             ExportedApi* entryPoint =
                 static_cast<ExportedApi*>