Fix returning empty value on getter 24/78424/4
authorSangyoon Jang <s89.jang@samsung.com>
Tue, 5 Jul 2016 11:36:52 +0000 (20:36 +0900)
committerSangyoon Jang <s89.jang@samsung.com>
Wed, 13 Jul 2016 04:44:13 +0000 (21:44 -0700)
Change-Id: I8e23937b0f455a2a140ee84930739670241f910c
Signed-off-by: Sangyoon Jang <s89.jang@samsung.com>
src/pkgmgrinfo_pkginfo.c

index 1b5548e..89dbc77 100644 (file)
@@ -1181,15 +1181,12 @@ API int pkgmgrinfo_pkginfo_get_icon(pkgmgrinfo_pkginfo_h handle, char **icon)
        locale = info->locale;
        retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
 
-       if (info->pkg_info == NULL)
+       if (info->pkg_info == NULL || info->pkg_info->icon == NULL)
                return PMINFO_R_ERROR;
 
        for (tmp = info->pkg_info->icon; tmp; tmp = tmp->next) {
                ptr = (icon_x *)tmp->data;
-               if (ptr && ptr->text == NULL)
-                       ptr->text = strdup("");
                if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
-                               !strcasecmp(ptr->text, "(null)") ||
                                strcmp(ptr->lang, locale))
                        continue;
                *icon = (char *)ptr->text;
@@ -1199,8 +1196,6 @@ API int pkgmgrinfo_pkginfo_get_icon(pkgmgrinfo_pkginfo_h handle, char **icon)
        locale = DEFAULT_LOCALE;
        for (tmp = info->pkg_info->icon; tmp; tmp = tmp->next) {
                ptr = (icon_x *)tmp->data;
-               if (ptr && ptr->text == NULL)
-                       ptr->text = strdup("");
                if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
                                strcmp(ptr->lang, locale))
                        continue;
@@ -1208,7 +1203,9 @@ API int pkgmgrinfo_pkginfo_get_icon(pkgmgrinfo_pkginfo_h handle, char **icon)
                return PMINFO_R_OK;
        }
 
-       return PMINFO_R_ERROR;
+       *icon = "";
+
+       return PMINFO_R_OK;
 }
 
 API int pkgmgrinfo_pkginfo_get_label(pkgmgrinfo_pkginfo_h handle, char **label)
@@ -1224,10 +1221,11 @@ API int pkgmgrinfo_pkginfo_get_label(pkgmgrinfo_pkginfo_h handle, char **label)
        locale = info->locale;
        retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
 
+       if (info->pkg_info == NULL || info->pkg_info->label == NULL)
+               return PMINFO_R_ERROR;
+
        for (tmp = info->pkg_info->label; tmp != NULL; tmp = tmp->next) {
                ptr = (label_x *)tmp->data;
-               if (ptr && ptr->text == NULL)
-                       ptr->text = strdup("");
                if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
                                strcmp(ptr->lang, locale))
                        continue;
@@ -1238,8 +1236,6 @@ API int pkgmgrinfo_pkginfo_get_label(pkgmgrinfo_pkginfo_h handle, char **label)
        locale = DEFAULT_LOCALE;
        for (tmp = info->pkg_info->label; tmp != NULL; tmp = tmp->next) {
                ptr = (label_x *)tmp->data;
-               if (ptr && ptr->text == NULL)
-                       ptr->text = strdup("");
                if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
                                strcmp(ptr->lang, locale))
                        continue;
@@ -1247,7 +1243,9 @@ API int pkgmgrinfo_pkginfo_get_label(pkgmgrinfo_pkginfo_h handle, char **label)
                return PMINFO_R_OK;
        }
 
-       return PMINFO_R_ERROR;
+       *label = "";
+
+       return PMINFO_R_OK;
 }
 
 API int pkgmgrinfo_pkginfo_get_description(pkgmgrinfo_pkginfo_h handle, char **description)
@@ -1263,10 +1261,11 @@ API int pkgmgrinfo_pkginfo_get_description(pkgmgrinfo_pkginfo_h handle, char **d
        locale = info->locale;
        retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
 
+       if (info->pkg_info == NULL || info->pkg_info->description == NULL)
+               return PMINFO_R_ERROR;
+
        for (tmp = info->pkg_info->description; tmp; tmp = tmp->next) {
                ptr = (description_x *)tmp->data;
-               if (ptr && ptr->text == NULL)
-                       ptr->text = strdup("");
                if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
                                strcmp(ptr->lang, locale))
                        continue;
@@ -1277,8 +1276,6 @@ API int pkgmgrinfo_pkginfo_get_description(pkgmgrinfo_pkginfo_h handle, char **d
        locale = DEFAULT_LOCALE;
        for (tmp = info->pkg_info->description; tmp; tmp = tmp->next) {
                ptr = (description_x *)tmp->data;
-               if (ptr && ptr->text == NULL)
-                       ptr->text = strdup("");
                if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
                                strcmp(ptr->lang, locale))
                        continue;
@@ -1286,7 +1283,9 @@ API int pkgmgrinfo_pkginfo_get_description(pkgmgrinfo_pkginfo_h handle, char **d
                return PMINFO_R_OK;
        }
 
-       return PMINFO_R_ERROR;
+       *description = "";
+
+       return PMINFO_R_OK;
 }
 
 API int pkgmgrinfo_pkginfo_get_author_name(pkgmgrinfo_pkginfo_h handle, char **author_name)