diff options
author | Ulrich Drepper <drepper@redhat.com> | 2000-07-16 04:35:55 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2000-07-16 04:35:55 +0000 |
commit | 9ff9add9a5812f6677d22c7d6bb17471cfc9025b (patch) | |
tree | 948d5f982e1eca31f9accea7919e78984cc54094 /sysdeps | |
parent | e993e9cc1c6b0dbe4c3d12ab7fe45678e3e39e27 (diff) | |
download | glibc-9ff9add9a5812f6677d22c7d6bb17471cfc9025b.zip glibc-9ff9add9a5812f6677d22c7d6bb17471cfc9025b.tar.gz glibc-9ff9add9a5812f6677d22c7d6bb17471cfc9025b.tar.bz2 |
Update.
2000-07-15 Ulrich Drepper <drepper@redhat.com>
* sysdeps/unix/sysv/linux/getcwd.c: Correct last patch.
Patch by Greg McGary <greg@mcgary.org>.
* io/Makefile (tests): Add tst-getcwd.
* io/tst-getcwd.c: New file.
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/unix/sysv/linux/getcwd.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/sysdeps/unix/sysv/linux/getcwd.c b/sysdeps/unix/sysv/linux/getcwd.c index b819f94..da42f48 100644 --- a/sysdeps/unix/sysv/linux/getcwd.c +++ b/sysdeps/unix/sysv/linux/getcwd.c @@ -104,13 +104,14 @@ __getcwd (char *buf, size_t size) if (retval >= 0) { if (buf == NULL && size == 0) - { - /* Ensure that the buffer is only as large as necessary. */ - buf = realloc (path, (size_t) retval); - if (buf == NULL) - /* `realloc' failed but we still have the original string. */ - buf = path; - } + /* Ensure that the buffer is only as large as necessary. */ + buf = realloc (path, (size_t) retval); + + if (buf == NULL) + /* Either buf was NULL all along, or `realloc' failed but + we still have the original string. */ + buf = path; + return buf; } @@ -156,13 +157,13 @@ __getcwd (char *buf, size_t size) path[n] = '\0'; if (buf == NULL && size == 0) - { - /* Ensure that the buffer is only as large as necessary. */ - buf = realloc (path, (size_t) n + 1); - if (buf == NULL) - /* `relloc' failed but we still have the original string. */ - buf = path; - } + /* Ensure that the buffer is only as large as necessary. */ + buf = realloc (path, (size_t) n + 1); + if (buf == NULL) + /* Either buf was NULL all along, or `realloc' failed but + we still have the original string. */ + buf = path; + return buf; } #ifndef have_new_dcache |