]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
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>
Mon, 23 Sep 2019 13:12:54 +0000 (14:12 +0100)
commit5f8199783433ce8f5b924c2640953b21b5d71620
tree787d91fc8b7742f6dfa5cfa824847281cc936972
parentc37135b645c3344808641a91422bad0cb916a514
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.

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