From: Heiko Schlittermann (HS12-RIPE) Date: Sun, 12 Feb 2017 18:23:12 +0000 (+0100) Subject: os_getcwd(): do not realloc if there was no malloc(). X-Git-Tag: exim-4.90devstart~1 X-Git-Url: https://git.exim.org/exim.git/commitdiff_plain/4a5ee04fd186cb7d86a4f70821dacc55f8cce98d os_getcwd(): do not realloc if there was no malloc(). --- 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