Fixed crash when get detail info
authorSoyoung Kim <sy037.kim@samsung.com>
Mon, 22 Apr 2013 12:58:59 +0000 (21:58 +0900)
committerSoyoung Kim <sy037.kim@samsung.com>
Mon, 22 Apr 2013 12:58:59 +0000 (21:58 +0900)
[Issue#] N/A
[Problem] occur crash
[Cause] wrong use Glist.
[Solution] fix add glist.
[SCMRequest] N/A

Change-Id: Ie11914681769caade72ac7366d70b32ee760a05c

src/pkg-manager/backendlib.cpp

index 5637e1f..b342b1a 100644 (file)
@@ -419,28 +419,28 @@ int getWidgetDetailInfoFromPackage(const char* pkgPath,
                 PKG_VALUE_STRING_LEN_MAX - 1);
     }
 
-    std::string icon_name;
+    GList *privilege_list = pkg_detail_info->privilege_list;
 
+    FOREACH(it, configInfo.featuresList) {
+        std::string featureInfo =  DPL::ToUTF8String(it->name);
+        LogDebug("privilege : " << featureInfo);
+        int length = featureInfo.size();
+        char *privilege = (char*) calloc(1, (sizeof(char) * (length + 1)));
+        snprintf(privilege, length + 1, "%s", featureInfo.c_str());
+        privilege_list = g_list_append(privilege_list, &privilege);
+    }
+
+    std::string icon_name;
     FOREACH(i, configInfo.iconsList) {
         LogDebug("icon name: " << i->src);
         icon_name = DPL::ToUTF8String(i->src);
         break;
     }
+
     pkg_detail_info->icon_buf = getIconInfo(widget_path, icon_name,
             pkg_detail_info->icon_size);
     LogDebug("icon size : " << pkg_detail_info->icon_size);
 
-    GList *privilege_list = NULL;
-    FOREACH(it, configInfo.featuresList) {
-        LogDebug("privilege : " << it->name);
-        int length = DPL::ToUTF8String(it->name).length();
-        char *privilege = (char*) calloc(1, (sizeof(char) * length) + 1);
-        snprintf(privilege, length + 1, "%s",
-                DPL::ToUTF8String(it->name).c_str());
-        privilege_list = g_list_append(privilege_list, privilege);
-    }
-    pkg_detail_info->privilege_list = privilege_list;
-
     return TRUE;
 }
 
@@ -455,8 +455,10 @@ static int pkg_plugin_get_app_detail_info_from_package(
 pkgmgr_info *pkgmgr_client_check_pkginfo_from_file(const char *pkg_path)
 {
     LogDebug("pkgmgr_client_check_pkginfo_from_file() is called");
-    package_manager_pkg_detail_info_t pkg_detail_info;
-    int ret = getWidgetDetailInfoFromPackage(pkg_path, &pkg_detail_info);
+    package_manager_pkg_detail_info_t *pkg_detail_info;
+    pkg_detail_info = (package_manager_pkg_detail_info_t*)malloc(
+            sizeof(package_manager_pkg_info_t));
+    int ret = getWidgetDetailInfoFromPackage(pkg_path, pkg_detail_info);
     if (FALSE == ret) {
         LogError("Failed to get package detail info ");
         return NULL;