kgiusti commented on a change in pull request #1075:
URL: https://github.com/apache/qpid-dispatch/pull/1075#discussion_r596228606
##########
File path: src/hash.c
##########
@@ -105,11 +106,24 @@ qd_hash_t *qd_hash(int bucket_exponent, int batch_size,
int value_is_const)
//remove the given item from the given bucket of the given hash
//return the key if non-null key pointer given, otherwise, free the memory
static void qd_hash_internal_remove_item(qd_hash_t *h, bucket_t *bucket,
qd_hash_item_t *item, unsigned char **key) {
- if (key)
+ if (key) {
*key = item->key;
- else
+ }
+ else {
free(item->key);
+ item->key = 0;
+ }
DEQ_REMOVE(bucket->items, item);
+
+ //
+ // We are going to free this item, so we will set the
+ // item pointer on the hash_handle to zero so nobody with
+ // access to the hash_handle can ever try to get to this freed item.
+ // The item and the hash_handle can be freed independent of one another.
+ //
+ if (item->handle) {
Review comment:
Why not make the handle->item a safe pointer to an item? Then you
wouldn't have to do this storing/clearing of the handle pointer in the item
itself.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]