[WGID 141790] Fix svace issue - DEREF_OF_NULL.RET.PROC.STAT 93/105393/1 accepted/tizen/3.0/mobile/20161219.095701 submit/tizen_3.0/20161216.102722
authorjin0.kim <jin0.kim@samsung.com>
Fri, 16 Dec 2016 10:23:35 +0000 (18:53 +0830)
committerjin0.kim <jin0.kim@samsung.com>
Fri, 16 Dec 2016 10:24:29 +0000 (18:54 +0830)
Change-Id: I845a8137ebcac96edce9dcc4097d6ed5bb4b180b

src/common.c

index 1f63015..7bacbb3 100755 (executable)
@@ -564,7 +564,7 @@ HAPI int quickpanel_common_launch_app(char *app_id, void *data)
 const char *util_get_file_path(enum app_subdir dir, const char *relative)
 {
        static char buf[PATH_MAX];
-       char *prefix;
+       char *prefix = NULL;
 
        switch (dir) {
        case APP_DIR_DATA:
@@ -595,15 +595,17 @@ const char *util_get_file_path(enum app_subdir dir, const char *relative)
                LOGE("Not handled directory type.");
                return NULL;
        }
-       size_t res = eina_file_path_join(buf, sizeof(buf), prefix, relative);
-       snprintf(buf, sizeof(buf), "%s%s", prefix, relative);
-       DBG("%s", buf);
-       free(prefix);
 
-       if (res > sizeof(buf)) {
-               LOGE("Path exceeded PATH_MAX");
-               return NULL;
-       }
+       if (prefix != NULL) {
+               size_t res = eina_file_path_join(buf, sizeof(buf), prefix, relative);
+               snprintf(buf, sizeof(buf), "%s%s", prefix, relative);
+               DBG("%s", buf);
+               free(prefix);
 
+               if (res > sizeof(buf)) {
+                       LOGE("Path exceeded PATH_MAX");
+                       return NULL;
+               }
+       }
        return &buf[0];
 }