]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
text_backend: avoid memory leaks when reload/clearing (#2188)
authorJoshua Rogers <MegaManSec@users.noreply.github.com>
Sun, 7 Sep 2025 23:04:46 +0000 (23:04 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Sun, 7 Sep 2025 23:04:58 +0000 (23:04 +0000)
src/auth/digest/file/text_backend.cc

index abcd70dd8c58d1db1143948c09bcce27b8f0e963..d0d363e6c957a99e894a773edaf0328b626b1881 100644 (file)
@@ -56,6 +56,7 @@ my_free(void *p)
     user_data *u = static_cast<user_data*>(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'))