Skip to content

Commit 25f720c

Browse files
committed
DISPATCH-2045: If the handle being freed points to an item, make sure to zero out the item's handle so it cannot be dereferenced later. This closes #1119.
1 parent cf64a5e commit 25f720c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/hash.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,16 @@ qd_error_t qd_hash_remove_str(qd_hash_t *h, const unsigned char *key)
445445

446446
void qd_hash_handle_free(qd_hash_handle_t *handle)
447447
{
448-
if (handle)
448+
if (handle) {
449+
//
450+
// The hash handle is being freed. if the handle points to an item, make sure to zero out the
451+
// item's handle so it cannot be dereferenced later.
452+
//
453+
if (handle->item && handle->item->handle) {
454+
handle->item->handle = 0;
455+
}
449456
free_qd_hash_handle_t(handle);
457+
}
450458
}
451459

452460

0 commit comments

Comments
 (0)