From 9ff9add9a5812f6677d22c7d6bb17471cfc9025b Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sun, 16 Jul 2000 04:35:55 +0000 Subject: Update. 2000-07-15 Ulrich Drepper * sysdeps/unix/sysv/linux/getcwd.c: Correct last patch. Patch by Greg McGary . * io/Makefile (tests): Add tst-getcwd. * io/tst-getcwd.c: New file. --- sysdeps/unix/sysv/linux/getcwd.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'sysdeps/unix/sysv') diff --git a/sysdeps/unix/sysv/linux/getcwd.c b/sysdeps/unix/sysv/linux/getcwd.c index b819f948fd..da42f48239 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 -- cgit v1.2.3