From: Alexandre Oliva Date: Thu, 29 Dec 2022 17:33:03 +0000 (-0300) Subject: hash set: reject attempts to add empty values X-Git-Tag: basepoints/gcc-14~2278 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1b9270852055f2641520fadd63328f997e76d367;p=thirdparty%2Fgcc.git hash set: reject attempts to add empty values Check, after adding a key to a hash set, that the entry does not look empty. for gcc/ChangeLog * hash-set.h (add): Check that the inserted entry does not look empty. --- diff --git a/gcc/hash-set.h b/gcc/hash-set.h index 76fa7f394561..a98121a060ee 100644 --- a/gcc/hash-set.h +++ b/gcc/hash-set.h @@ -58,7 +58,11 @@ public: Key *e = m_table.find_slot_with_hash (k, Traits::hash (k), INSERT); bool existed = !Traits::is_empty (*e); if (!existed) - new (e) Key (k); + { + new (e) Key (k); + // Catch attempts to insert e.g. a NULL pointer. + gcc_checking_assert (!Traits::is_empty (*e)); + } return existed; }