mirror of
https://github.com/nmap/nmap.git
synced 2025-12-07 13:11:28 +00:00
Ensure gh_heap node addresses are NULL when invalid.
This commit is contained in:
@@ -173,6 +173,7 @@ static int heap_grow(gh_heap_t *heap) {
|
|||||||
heap->slots = (gh_hnode_t **)safe_realloc(heap->slots,
|
heap->slots = (gh_hnode_t **)safe_realloc(heap->slots,
|
||||||
newsize * sizeof(gh_hnode_t *));
|
newsize * sizeof(gh_hnode_t *));
|
||||||
heap->highwm += GH_SLOTS;
|
heap->highwm += GH_SLOTS;
|
||||||
|
memset(heap->slots + heap->count, 0, GH_SLOTS * sizeof(gh_hnode_t *));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,6 +214,7 @@ int gh_heap_push(gh_heap_t *heap, gh_hnode_t *hnode) {
|
|||||||
|
|
||||||
hnode->index = new_index;
|
hnode->index = new_index;
|
||||||
new_ptr = hnode_ptr(heap, new_index);
|
new_ptr = hnode_ptr(heap, new_index);
|
||||||
|
assert(*new_ptr == NULL);
|
||||||
heap->count++;
|
heap->count++;
|
||||||
*new_ptr = hnode;
|
*new_ptr = hnode;
|
||||||
|
|
||||||
@@ -245,5 +247,7 @@ int gh_heap_remove(gh_heap_t *heap, gh_hnode_t *hnode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gh_hnode_invalidate(hnode);
|
gh_hnode_invalidate(hnode);
|
||||||
|
cur_ptr = hnode_ptr(heap, count);
|
||||||
|
*cur_ptr = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user