From c4ca119eb616b1e699f08d4f5a36d6c205431d11 Mon Sep 17 00:00:00 2001 From: phk Date: Sat, 5 Aug 2006 14:22:33 +0000 Subject: [PATCH] More defensive coding. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@669 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/lib/libvarnish/binary_heap.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/varnish-cache/lib/libvarnish/binary_heap.c b/varnish-cache/lib/libvarnish/binary_heap.c index 5a5a8977..8c008b98 100644 --- a/varnish-cache/lib/libvarnish/binary_heap.c +++ b/varnish-cache/lib/libvarnish/binary_heap.c @@ -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); -- 2.39.5