Fix TC-1539 33/26733/1 submit/tizen_common/20140828.122453 submit/tizen_ivi/20140829.000000
authorBaptiste DURAND <baptiste.durand@open.eurogiciel.org>
Thu, 28 Aug 2014 11:50:59 +0000 (13:50 +0200)
committerBaptiste DURAND <baptiste.durand@open.eurogiciel.org>
Thu, 28 Aug 2014 11:50:59 +0000 (13:50 +0200)
Fix icon management to avoid segfault during pkginit_db execution

Change-Id: Ie52a5e87e526ec85ec0ce45310c2732e1576faa0
Signed-off-by: Baptiste DURAND <baptiste.durand@open.eurogiciel.org>
parser/pkgmgr_parser.c

index bf7a0d4..1042f36 100755 (executable)
@@ -3042,6 +3042,7 @@ __get_icon_with_path(const char* icon, uid_t uid)
                char* theme = NULL;
                char* iconPath = NULL;
                char* icon_with_path = NULL;
+               char *app_path = NULL;
                int len;
 
                if (!package)
@@ -3073,19 +3074,17 @@ __get_icon_with_path(const char* icon, uid_t uid)
                        snprintf(icon_with_path, len, "%s%s", getIconPath(uid), icon);
                else {
                        snprintf(icon_with_path, len, "%s%s/small/%s", getIconPath(GLOBAL_USER), theme, icon);
-                       if (!access (icon_with_path, F_OK))
-                               snprintf( len, icon_with_path, "%s/%q/res/icons/%q/small/%q", tzplatform_getenv(TZ_SYS_RO_APP), package, theme, icon);
-                       else if (!access (icon_with_path, F_OK))
-                               snprintf( len, icon_with_path, "%s/%q/res/icons/%q/small/%q", tzplatform_getenv(TZ_SYS_RW_APP), package, theme, icon);
+                       if (access (icon_with_path, F_OK)) { //If doesn't exist in case of Global app, try to get icon directly into app's directory
+                               app_path = tzplatform_getenv(TZ_SYS_RW_APP);
+                               if (app_path)
+                                       snprintf( len, icon_with_path, "%s/%q/res/icons/%q/small/%q", app_path  , package, theme, icon);
+                               if (access (icon_with_path, F_OK))
+                                       _LOGE("Cannot find icon path");
                        }
-                       if (!access (icon_with_path, F_OK))
-                               _LOGD("Cannot find icon path");
-
-                       free(theme);
-
-                       _LOGD("Icon path : %s ---> %s", icon, icon_with_path);
-
-                       return icon_with_path;
+               }
+               free(theme);
+               _LOGD("Icon path : %s ---> %s", icon, icon_with_path);
+               return icon_with_path;
        } else {
                char* confirmed_icon = NULL;