eina utils: fix build without getpwent.

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
This commit is contained in:
Mykyta Biliavskyi 2017-02-20 11:29:56 +02:00
parent 80e3c643d8
commit 94eaa792c2
1 changed files with 6 additions and 4 deletions

View 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;