]> err.no Git - varnish/commitdiff
More defensive coding.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sat, 5 Aug 2006 14:22:33 +0000 (14:22 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sat, 5 Aug 2006 14:22:33 +0000 (14:22 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@669 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/lib/libvarnish/binary_heap.c

index 5a5a897721739e4ee87bbc33899cda86952164b0..8c008b98a56ac630df92dbd91872b13538ee1029 100644 (file)
@@ -178,10 +178,14 @@ binheap_delete(struct binheap *bh, unsigned idx)
        assert(bh->next > ROOT_IDX);
        assert(idx < bh->next);
        assert(idx > 0);
+       assert(bh->array[idx] != NULL);
        bh->update(bh->priv, bh->array[idx], 0);
-       if (idx == --bh->next)
+       if (idx == --bh->next) { 
+               bh->array[bh->next] = NULL;
                return;
+       }
        bh->array[idx] = bh->array[bh->next];
+       bh->array[bh->next] = NULL;
        binheap_update(bh, idx);
        idx = binheap_trickleup(bh, idx);
        binheap_trickledown(bh, idx);