summaryrefslogtreecommitdiffstats
path: root/findexec.c
diff options
context:
space:
mode:
Diffstat (limited to 'findexec.c')
-rwxr-xr-x[-rw-r--r--]findexec.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/findexec.c b/findexec.c
index a562077..5be7f54 100644..100755
--- a/findexec.c
+++ b/findexec.c
@@ -1,5 +1,6 @@
/* "findexec.c" was part of DLD, a dynamic link/unlink editor for C.
- * Copyright (C) 1990 by W. Wilson Ho.
+ * Copyright (C) 1990 Free Software Foundation
+ * Author: W. Wilson Ho.
*
* GNU Emacs is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -148,6 +149,7 @@ static char *copy_of(s)
# define ABSOLUTE_FILENAME_P(fname) (fname[0] == '/')
# endif /* atarist */
+/* Return 0 if getcwd() returns 0. */
char *dld_find_executable(name)
const char *name;
{
@@ -160,7 +162,7 @@ char *dld_find_executable(name)
if (strchr(name, '/')) {
strcpy (tbuf, "."); /* in case getcwd doesn't work */
- getcwd(tbuf, MAXPATHLEN);
+ if (!getcwd(tbuf, MAXPATHLEN)) return (char *)0L;
if ((name[0] == '.') && (name[1] == '/')) {
strcat(tbuf, name + 1);
} else {
@@ -190,8 +192,9 @@ char *dld_find_executable(name)
*next = 0;
if (*p) p++;
- if (tbuf[0] == '.' && tbuf[1] == 0)
- getcwd(tbuf, MAXPATHLEN); /* was getwd(tbuf); */
+ if (tbuf[0] == '.' && tbuf[1] == 0) {
+ if (!getcwd(tbuf, MAXPATHLEN)) return (char *)0L;
+ }
else if (tbuf[0]=='~' && tbuf[1]==0 && getenv("HOME"))
strcpy(tbuf, (char *)getenv("HOME"));