diff options
author | Dylan Baker <dylan.c.baker@intel.com> | 2023-02-23 09:50:33 -0800 |
---|---|---|
committer | Eric Engestrom <eric@engestrom.ch> | 2023-03-08 18:00:13 +0000 |
commit | 55b6c88d4d0146c80c25272564ceaa84fafe7eed (patch) | |
tree | a525ecdb4f90942d3ea8c12b3349c366fc40a85b | |
parent | 57be6f6ef268fd31f2629b379c5dcb428e8ee6da (diff) | |
download | mesa-55b6c88d4d0146c80c25272564ceaa84fafe7eed.tar.gz |
util: rzalloc and free hash_table_u64
Otherwise we're prone to leaking the table itself, since it's not freed
in the destroy function
CID: 1516552
fixes: 6649b840c34016b4753e69d4513a8d09da9febb2
("mesa/util: add a hash table wrapper which support 64-bit keys")
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21499>
(cherry picked from commit ff494361bee7506db701cb861073ab194ae3a6e9)
-rw-r--r-- | .pick_status.json | 2 | ||||
-rw-r--r-- | src/util/hash_table.c | 11 |
2 files changed, 5 insertions, 8 deletions
diff --git a/.pick_status.json b/.pick_status.json index 9fd2c4d63d4..83fbb2e097d 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -4297,7 +4297,7 @@ "description": "util: rzalloc and free hash_table_u64", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "6649b840c34016b4753e69d4513a8d09da9febb2" }, diff --git a/src/util/hash_table.c b/src/util/hash_table.c index b0e7506ab8e..dc00b2de8e9 100644 --- a/src/util/hash_table.c +++ b/src/util/hash_table.c @@ -775,15 +775,15 @@ _mesa_hash_table_u64_create(void *mem_ctx) STATIC_ASSERT(FREED_KEY_VALUE != DELETED_KEY_VALUE); struct hash_table_u64 *ht; - ht = CALLOC_STRUCT(hash_table_u64); + ht = rzalloc(mem_ctx, struct hash_table_u64); if (!ht) return NULL; if (sizeof(void *) == 8) { - ht->table = _mesa_hash_table_create(mem_ctx, _mesa_hash_pointer, + ht->table = _mesa_hash_table_create(ht, _mesa_hash_pointer, _mesa_key_pointer_equal); } else { - ht->table = _mesa_hash_table_create(mem_ctx, key_u64_hash, + ht->table = _mesa_hash_table_create(ht, key_u64_hash, key_u64_equals); } @@ -821,10 +821,7 @@ _mesa_hash_table_u64_destroy(struct hash_table_u64 *ht) { if (!ht) return; - - _mesa_hash_table_u64_clear(ht); - _mesa_hash_table_destroy(ht->table, NULL); - free(ht); + ralloc_free(ht); } void |