]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
bug: cbdataUnlock would free() if the ptr was not valid, but still had locks
authorwessels <>
Sun, 10 Aug 1997 12:29:21 +0000 (12:29 +0000)
committerwessels <>
Sun, 10 Aug 1997 12:29:21 +0000 (12:29 +0000)
src/cbdata.cc

index 5e9d79a4e13b5184b8d6e6eb7c999003db44e1c5..ee3583e3b62815298eabd041657619a229d2b9c8 100644 (file)
@@ -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);
 }