eina_vpath_xdg: fix fallback strings
authorMarcel Hollerbach <mail@marcel-hollerbach.de>
Thu, 18 Oct 2018 12:00:33 +0000 (14:00 +0200)
committerYeongjong Lee <yj34.lee@samsung.com>
Thu, 8 Nov 2018 06:40:45 +0000 (15:40 +0900)
when more than one fallback string was used the same variable was
accidently used again and again. This fixes that.

Note: This was not discovered because elementary does not use xdg per
default :)

Differential Revision: https://phab.enlightenment.org/D7174

src/lib/eina/eina_vpath_xdg.c

index 2d53304..c38d3d9 100644 (file)
@@ -13,7 +13,6 @@
 void
 eina_xdg_env_init(void)
 {
-   char buf[PATH_MAX];
    char *s;
    char home[PATH_MAX];
    Eina_Vpath_Interface_User user;
@@ -24,16 +23,18 @@ eina_xdg_env_init(void)
 
 # if defined(HAVE_GETUID) && defined(HAVE_GETEUID)
 #  define ENV_HOME_SET(_env, _dir, _meta) \
+   char _meta [PATH_MAX]; \
    if ((getuid() != geteuid()) || (!(s = getenv(_env)))) { \
-      snprintf(buf, sizeof(buf), "%s/"_dir, home); \
-      s = buf; \
+      snprintf(_meta, sizeof(_meta), "%s/"_dir, home); \
+      s = _meta; \
    } \
    (&user)->_meta = s;
 #else
 #  define ENV_HOME_SET(_env, _dir, _meta) \
+   char _meta [PATH_MAX]; \
    if (!(s = getenv(_env))) { \
-      snprintf(buf, sizeof(buf), "%s/"_dir, home); \
-      s = buf; \
+      snprintf(_meta, sizeof(_meta), "%s/"_dir, home); \
+      s = _meta; \
    } \
    (&user)->_meta = s;
 #endif