Fix possible memory leak condition in PPM for Tizen Platform.
authorSatya Prakash Gupta <sp.gupta@samsung.com>
Thu, 11 Jun 2015 13:43:08 +0000 (19:13 +0530)
committerUze Choi <uzchoi@samsung.com>
Mon, 22 Jun 2015 06:42:08 +0000 (06:42 +0000)
API app_get_id allocates memory internally, which was not freed
resulting in possible memory leak.

Signed-off-by: Satya Prakash Gupta <sp.gupta@samsung.com>
Change-Id: Ibc2cc77ebe803f174ab5e7ec5cff18e54178f2a8
Reviewed-on: https://gerrit.iotivity.org/gerrit/1239
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
Reviewed-by: Harish Marappa <h.marappa@samsung.com>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
Tested-by: Uze Choi <uzchoi@samsung.com>
service/protocol-plugin/plugin-manager/src/Config.cpp

index 9d8ec9b..b2e3044 100644 (file)
@@ -50,16 +50,15 @@ Config::Config(void *args)
     if (path != ".")
         path = "/data/data/" + path + "/files";
 #elif __TIZEN__
-    char *app_id = (char *)malloc(PATH_MAX_SIZE * sizeof(char));
-    char completePath[PATH_MAX_SIZE];
+    char *app_id = NULL;
     int res = app_get_id(&app_id);
     if (APP_ERROR_NONE == res)
     {
-        strcpy(completePath, "/opt/usr/apps/");
-        strcat(completePath, app_id);
-        strcat(completePath, "/lib");
+        path = "/opt/usr/apps/";
+        path += app_id;
+        path += "/lib";
     }
-    path = completePath;
+    free(app_id);
 #endif
 
     if (loadConfigFile(path + "/pluginmanager.xml") != PM_S_OK)