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:
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];
}