Commit e95d58c0 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

More defensive coding.


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@669 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 12898505
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment