From: Heiko Schlittermann (HS12-RIPE) Date: Sun, 12 Feb 2017 21:50:18 +0000 (-0500) Subject: os_getcwd(): do not realloc if there was no malloc(). X-Git-Tag: exim-4_89_RC5 X-Git-Url: https://git.exim.org/exim.git/commitdiff_plain/exim-4_89_RC5?hp=d195b66d38fd2ef7407705eba04bb8b6953cd41d os_getcwd(): do not realloc if there was no malloc(). (cherry picked from commit 4a5ee04fd186cb7d86a4f70821dacc55f8cce98d) (changelog added) Signed-off-by: Phil Pennock --- diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index 0af5504e3..39e17b350 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -6,7 +6,7 @@ options, and new features, see the NewStuff file next to this ChangeLog. Exim version 4.89 -------------------- +----------------- JH/01 Bug 1922: Support IDNA2008. This has slightly different conversion rules than -2003 did; needs libidn2 in addition to libidn. @@ -99,6 +99,9 @@ PP/08 Reduce a number of compilation warnings under clang; building with JH/17 Fix inbound CHUNKING when DKIM disabled at runtime. +HS/01 Fix portability problems introduced by PP/08 for platforms where + realloc(NULL) is not equivalent to malloc() [SunOS et al]. + Exim version 4.88 ----------------- 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