From: serassio <> Date: Mon, 2 Oct 2006 00:40:29 +0000 (+0000) Subject: Bug #1782: Memory leak in ncsa_auth on password changes X-Git-Tag: SQUID_3_0_PRE5~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5fb27788b825f88b805819539c5ca40ce0f85ee3;p=thirdparty%2Fsquid.git Bug #1782: Memory leak in ncsa_auth on password changes Forward port of a 2.6 patch. --- diff --git a/helpers/basic_auth/NCSA/ncsa_auth.c b/helpers/basic_auth/NCSA/ncsa_auth.c index 98bf691be3..07e5f7b045 100644 --- a/helpers/basic_auth/NCSA/ncsa_auth.c +++ b/helpers/basic_auth/NCSA/ncsa_auth.c @@ -73,6 +73,7 @@ read_passwd_file(const char *passwdfile) char *passwd; if (hash != NULL) { hashFreeItems(hash, my_free); + hashFreeMemory(hash); } /* initial setup */ hash = hash_create((HASHCMP *) strcmp, 7921, hash_string); @@ -137,7 +138,7 @@ main(int argc, char **argv) } rfc1738_unescape(user); rfc1738_unescape(passwd); - u = (user_data *)hash_lookup(hash, user); + u = (user_data *) hash_lookup(hash, user); if (u == NULL) { printf("ERR No such user\n"); } else if (strcmp(u->passwd, (char *) crypt(passwd, u->passwd)) == 0) { @@ -148,5 +149,9 @@ main(int argc, char **argv) printf("ERR Wrong password\n"); } } + if (hash != NULL) { + hashFreeItems(hash, my_free); + hashFreeMemory(hash); + } exit(0); }