From 22327e4bb5b9fd17c31373a34aec424bf825438a Mon Sep 17 00:00:00 2001 From: Jamal Haidar Date: Tue, 16 Jun 2015 16:57:39 +0530 Subject: [PATCH] Fix possible memory leak condition in PPM for Tizen Platform. API app_get_id allocates memory internally, which was not freed resulting in possible memory leak. Change-Id: I513bda2dbb407eedd9e855703188eab180974122 Signed-off-by: Jamal Haidar Reviewed-on: https://gerrit.iotivity.org/gerrit/1281 Tested-by: jenkins-iotivity Reviewed-by: Harish Marappa Reviewed-by: Uze Choi --- .../protocol-plugin/plugin-manager/src/PluginManager.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/service/protocol-plugin/plugin-manager/src/PluginManager.cpp b/service/protocol-plugin/plugin-manager/src/PluginManager.cpp index 18c6101..16a861b 100644 --- a/service/protocol-plugin/plugin-manager/src/PluginManager.cpp +++ b/service/protocol-plugin/plugin-manager/src/PluginManager.cpp @@ -33,16 +33,18 @@ using namespace OIC; PluginManager::PluginManager() { #ifdef __TIZEN__ - char *app_id = (char *)malloc(PATH_MAX_SIZE * sizeof(char)); - char completePath[PATH_MAX_SIZE]; + char *app_id = NULL; + std::string completePath = ""; int res = app_get_id(&app_id); if (APP_ERROR_NONE == res) { - strcpy(completePath, "/opt/usr/apps/"); - strcat(completePath, app_id); - strcat(completePath, "/lib/libpmimpl.so"); + completePath = "/opt/usr/apps/"; + completePath += app_id; + completePath += "/lib/libpmimpl.so"; } - handle = dlopen(completePath, RTLD_LAZY); + free(app_id); + app_id = NULL; + handle = dlopen(completePath.c_str(), RTLD_LAZY); #else handle = dlopen("./libpmimpl.so", RTLD_LAZY); #endif //#ifdef __TIZEN__ @@ -87,4 +89,4 @@ std::vector PluginManager::getPlugins(void) std::string PluginManager::getState(const std::string plugID) { return pluginManagerImpl->getState(plugID); -} \ No newline at end of file +} -- 2.7.4