From aab9676e9df4079b5a6dca37f36ffaad6a4438a1 Mon Sep 17 00:00:00 2001 From: wessels <> Date: Sun, 10 Aug 1997 12:29:21 +0000 Subject: [PATCH] bug: cbdataUnlock would free() if the ptr was not valid, but still had locks --- src/cbdata.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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); } -- 2.47.3