diff options
Diffstat (limited to 'sysdeps/posix')
-rw-r--r-- | sysdeps/posix/tempname.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/sysdeps/posix/tempname.c b/sysdeps/posix/tempname.c index 1a113757aa..5b6134cb24 100644 --- a/sysdeps/posix/tempname.c +++ b/sysdeps/posix/tempname.c @@ -69,14 +69,17 @@ __path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx, else if (dir != NULL && direxists (dir)) /* nothing */ ; } - if (direxists (P_tmpdir)) - dir = P_tmpdir; - else if (strcmp (P_tmpdir, "/tmp") != 0 && direxists ("/tmp")) - dir = "/tmp"; - else + if (dir != NULL) { - __set_errno (ENOENT); - return -1; + if (direxists (P_tmpdir)) + dir = P_tmpdir; + else if (strcmp (P_tmpdir, "/tmp") != 0 && direxists ("/tmp")) + dir = "/tmp"; + else + { + __set_errno (ENOENT); + return -1; + } } dlen = strlen (dir); |