eina utils: fix build without getpwent.
authorMykyta Biliavskyi <m.biliavskyi@samsung.com>
Mon, 20 Feb 2017 09:29:56 +0000 (11:29 +0200)
committerMykyta Biliavskyi <m.biliavskyi@samsung.com>
Mon, 20 Feb 2017 09:29:56 +0000 (11:29 +0200)
If HAVE_GETPWENT isn't defined - the closing brace was missed.
Also prevent situation when strdup() tried to duplicate NULL
pointer, because that could cause segfault.

@fix

src/lib/eina/eina_util.c

index 7205a45..1d329d2 100644 (file)
@@ -84,12 +84,14 @@ eina_environment_home_get(void)
         if (!getpwuid_r(geteuid(), &pwent, pwbuf, sizeof(pwbuf), &pwent2))
           {
              if ((pwent2) && (pwent.pw_dir))
-               home = strdup(pwent.pw_dir);
+               {
+                  home = strdup(pwent.pw_dir);
+                  return home;
+               }
           }
-        if (!home) home = strdup("/tmp");
-        return home;
-     }
 # endif
+        home = "/tmp";
+     }
 #endif
    home = strdup(home);
    return home;