diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2021-05-04 15:46:28 +0100 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2021-05-04 22:34:20 +0100 |
commit | ca871701c2822c3c4537745d4aa44a7b8f408337 (patch) | |
tree | a906537862fa90dd027e1bde018b7f0076843510 | |
parent | 6fb8b67089119b737ccb38f75f403b8d279e2229 (diff) | |
download | gcc-ca871701c2822c3c4537745d4aa44a7b8f408337.zip gcc-ca871701c2822c3c4537745d4aa44a7b8f408337.tar.gz gcc-ca871701c2822c3c4537745d4aa44a7b8f408337.tar.bz2 |
libstdc++: Fix null dereference in pb_ds containers
This fixes ubsan errors:
ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp:533:15: runtime error: member access within null pointer of type 'struct entry'
libstdc++-v3/ChangeLog:
* include/ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp
(find_key_pointer(key_const_reference, false_type))
(find_key_pointer(key_const_reference, true_type)): Do not
dereference null pointer.
-rw-r--r-- | libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp index aa5c94b..c81bf3a 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp @@ -524,13 +524,16 @@ namespace __gnu_pbds resize_base::notify_find_search_end(); -#ifdef _GLIBCXX_DEBUG if (p_e == 0) - PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) + { + PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) + return 0; + } else - PB_DS_CHECK_KEY_EXISTS(r_key) -#endif - return &p_e->m_value; + { + PB_DS_CHECK_KEY_EXISTS(r_key) + return &p_e->m_value; + } } inline pointer @@ -550,13 +553,16 @@ namespace __gnu_pbds resize_base::notify_find_search_end(); -#ifdef _GLIBCXX_DEBUG if (p_e == 0) - PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) + { + PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) + return 0; + } else - PB_DS_CHECK_KEY_EXISTS(r_key) -#endif - return &p_e->m_value; + { + PB_DS_CHECK_KEY_EXISTS(r_key) + return &p_e->m_value; + } } inline bool |