Skip to content

Commit

Permalink
util/hash: fix removal
Browse files Browse the repository at this point in the history
When removal is going to empty the bucket list, this does not mean
we don't need to compare the data.

Note: Nothing like fixing a 16 years old bug.

Ticket: 7475
  • Loading branch information
regit committed Jan 3, 2025
1 parent e74b865 commit b301bd9
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/util-hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,14 @@ int HashTableRemove(HashTable *ht, void *data, uint16_t datalen)
}

if (ht->array[hash]->next == NULL) {
if (ht->Free != NULL)
ht->Free(ht->array[hash]->data);
SCFree(ht->array[hash]);
ht->array[hash] = NULL;
return 0;
if (ht->Compare(ht->array[hash]->data, ht->array[hash]->size, data, datalen) == 1) {
if (ht->Free != NULL)
ht->Free(ht->array[hash]->data);
SCFree(ht->array[hash]);
ht->array[hash] = NULL;
return 0;
}
return -1;
}

HashTableBucket *hashbucket = ht->array[hash], *prev_hashbucket = NULL;
Expand Down

0 comments on commit b301bd9

Please sign in to comment.