diff options
author | Ian Lance Taylor <ian@airs.com> | 2000-02-22 16:18:13 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 2000-02-22 16:18:13 +0000 |
commit | 9e7fba8ade016a355d662ba84005773746a3c7c0 (patch) | |
tree | 66613bc864c3dd53c6ad2571513130fa98da08f2 /libiberty/getcwd.c | |
parent | f507d52b48cf10a4a5b82548478505edc89df964 (diff) | |
download | gdb-9e7fba8ade016a355d662ba84005773746a3c7c0.tar.gz |
import libiberty from egcs
Diffstat (limited to 'libiberty/getcwd.c')
-rw-r--r-- | libiberty/getcwd.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libiberty/getcwd.c b/libiberty/getcwd.c index 06d55c04f58..47b1c1eec31 100644 --- a/libiberty/getcwd.c +++ b/libiberty/getcwd.c @@ -14,6 +14,9 @@ DESCRIPTION current directory's path doesn't fit in LEN characters, the result is NULL and errno is set. + If pathname is a null pointer, getcwd() will obtain size bytes of + space using malloc. + BUGS Emulated via the getwd() call, which is reasonable for most systems that do not have getcwd(). @@ -48,6 +51,13 @@ getcwd (buf, len) errno = ERANGE; return 0; } + if (!buf) { + buf = (char*)malloc(len); + if (!buf) { + errno = ENOMEM; + return 0; + } + } strcpy (buf, ourbuf); } return buf; |