From: wessels <> Date: Sun, 10 Aug 1997 12:29:21 +0000 (+0000) Subject: bug: cbdataUnlock would free() if the ptr was not valid, but still had locks X-Git-Tag: SQUID_3_0_PRE1~4838 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=aab9676e9df4079b5a6dca37f36ffaad6a4438a1;p=thirdparty%2Fsquid.git bug: cbdataUnlock would free() if the ptr was not valid, but still had locks --- diff --git a/src/cbdata.cc b/src/cbdata.cc index 5e9d79a4e1..ee3583e3b6 100644 --- a/src/cbdata.cc +++ b/src/cbdata.cc @@ -58,7 +58,8 @@ cbdataFree(void *p) assert(c != NULL); c->valid = 0; if (c->locks) { - debug(45, 3) ("cbdataFree: %p has locks, not freeing\n", p); + debug(45, 3) ("cbdataFree: %p has %d locks, not freeing\n", + p, c->locks); return; } hash_remove_link(htable, (hash_link *) c); @@ -90,10 +91,11 @@ cbdataUnlock(void *p) assert(c != NULL); assert(c->locks > 0); c->locks--; - if (c->valid) + if (c->valid || c->locks) return; hash_remove_link(htable, (hash_link *) c); xfree(c); + debug(45, 3) ("cbdataUnlock: Freeing %p\n", p); xfree(p); }