From: Joshua Rogers Date: Sun, 7 Sep 2025 23:04:46 +0000 (+0000) Subject: text_backend: avoid memory leaks when reload/clearing (#2188) X-Git-Tag: SQUID_7_2~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=69af776a80ed49e008daff074478f63db2209fa9;p=thirdparty%2Fsquid.git text_backend: avoid memory leaks when reload/clearing (#2188) --- diff --git a/src/auth/digest/file/text_backend.cc b/src/auth/digest/file/text_backend.cc index abcd70dd8c..d0d363e6c9 100644 --- a/src/auth/digest/file/text_backend.cc +++ b/src/auth/digest/file/text_backend.cc @@ -56,6 +56,7 @@ my_free(void *p) user_data *u = static_cast(p); xfree(u->hash.key); xfree(u->passwd); + xfree(u->ha1); xfree(u); } @@ -71,6 +72,8 @@ read_passwd_file(const char *passwordFile, int isHa1Mode) if (hash != nullptr) { hashFreeItems(hash, my_free); + hashFreeMemory(hash); + hash = nullptr; } /* initial setup */ hash = hash_create((HASHCMP *) strcmp, 7921, hash_string); @@ -86,6 +89,7 @@ read_passwd_file(const char *passwordFile, int isHa1Mode) } unsigned int lineCount = 0; while (fgets(buf, sizeof(buf), f) != nullptr) { + ha1 = nullptr; ++lineCount; if ((buf[0] == '#') || (buf[0] == ' ') || (buf[0] == '\t') || (buf[0] == '\n'))