diff options
author | Heiko Schlittermann (HS12-RIPE) <hs@schlittermann.de> | 2017-02-12 19:23:12 +0100 |
---|---|---|
committer | Heiko Schlittermann (HS12-RIPE) <hs@schlittermann.de> | 2017-02-12 19:23:12 +0100 |
commit | 4a5ee04fd186cb7d86a4f70821dacc55f8cce98d (patch) | |
tree | 04f9d83da5ee580869fb063d605bab792608f53d | |
parent | 79de4f370f306869887e1714ff4ecef5bfc93fa5 (diff) |
os_getcwd(): do not realloc if there was no malloc().
-rw-r--r-- | src/src/os.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/src/os.c b/src/src/os.c index 47af038f7..ca24e8dd2 100644 --- a/src/src/os.c +++ b/src/src/os.c @@ -879,7 +879,7 @@ char * b = (char *)buffer; if (!size) size = PATH_MAX; if (!b && !(b = malloc(size))) return NULL; if (!(b = getcwd(b, size))) return NULL; -return realloc(b, strlen(b) + 1); +return buffer ? buffer : realloc(b, strlen(b) + 1); } #endif |