libctf: don't leak hash keys or values on value replacement
authorNick Alcock <nick.alcock@oracle.com>
Wed, 24 Jul 2019 14:21:56 +0000 (15:21 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Thu, 3 Oct 2019 16:04:55 +0000 (17:04 +0100)
commit1820745a0af0768d9dcd515b98ad038ff9f15f23
tree8904098f8a9792eefe985e0f194c2ac7a76333cb
parent5de9eada3b4e39c89431765b1c59159cb04878ed
libctf: don't leak hash keys or values on value replacement

When a ctf_dynhash_insert() finds a slot already existing, it should
call the key and value free functions on the existing key and value and
move the passed-in key into place, so that the lifetime rules for hash
keys are always the same no matter whether the key existed or not but
neither are the keys or values leaked.

New in v3.
v5: fix tabdamage.

libctf/
* ctf-hash.c (ctf_hashtab_insert): Pass in the key and value
freeing functions: if set, free the key and value if the slot
already exists.  Always reassign the key.
(ctf_dynhash_insert): Adjust call appropriately.
(ctf_hash_insert_type): Likewise.
libctf/ChangeLog
libctf/ctf-hash.c
This page took 0.025115 seconds and 4 git commands to generate.