This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.
Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
The (buf==NULL && size > 0) case is still broken. This fixes it: Index: sysdeps/unix/sysv/linux/getcwd.c =================================================================== RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/getcwd.c,v retrieving revision 1.16 diff -u -p -r1.16 getcwd.c --- getcwd.c 2000/07/13 17:42:32 1.16 +++ getcwd.c 2000/07/15 07:12:09 @@ -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
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |