From: Alex Rousskov Date: Wed, 21 Sep 2016 18:54:45 +0000 (-0600) Subject: Do reset $HOME if needed after r13435. Minimize putenv() memory leaks. X-Git-Tag: SQUID_4_0_15~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b1b2793926b56ec8132b911cf245c5dd46475d8e;p=thirdparty%2Fsquid.git Do reset $HOME if needed after r13435. Minimize putenv() memory leaks. While r13435 is attributed to me, the wrong condition was not mine. This is a good example of why "cmp() op 0" pattern is usually safer because the "==" or "!=" operator "tells" us whether the strings are equal, unlike "!cmp()" that is often misread as "not equal". --- diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 50e453366d..95c4515413 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -836,7 +836,7 @@ configDoConfigure(void) if (pwd->pw_dir && *pwd->pw_dir) { // putenv() leaks by design; avoid leaks when nothing changes static SBuf lastDir; - if (lastDir.isEmpty() || !lastDir.cmp(pwd->pw_dir)) { + if (lastDir.isEmpty() || lastDir.cmp(pwd->pw_dir) != 0) { lastDir = pwd->pw_dir; int len = strlen(pwd->pw_dir) + 6; char *env_str = (char *)xcalloc(len, 1);