diff options
author | Emmanuel Leblond <emmanuel.leblond@gmail.com> | 2020-02-01 07:04:14 +0100 |
---|---|---|
committer | Emmanuel Leblond <emmanuel.leblond@gmail.com> | 2021-10-30 13:11:01 +0200 |
commit | f9ba2efe1e60fa919b0efe70994416149b54ee26 (patch) | |
tree | 4cdf64b6325b49908973ad6f6ece9c5934e8d1d6 /core/templates | |
parent | 78f86ff5152074bcd6a19d05b028d2306c57ed67 (diff) |
Modify Dictionary::operator== to do real key/value comparison with recursive support (and add unittests)
Diffstat (limited to 'core/templates')
-rw-r--r-- | core/templates/ordered_hash_map.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/core/templates/ordered_hash_map.h b/core/templates/ordered_hash_map.h index 7a17eeb644..4996b88190 100644 --- a/core/templates/ordered_hash_map.h +++ b/core/templates/ordered_hash_map.h @@ -207,8 +207,12 @@ public: (*list_element)->get().second = p_value; return Element(*list_element); } - typename InternalList::Element *new_element = list.push_back(Pair<const K *, V>(nullptr, p_value)); + // Incorrectly set the first value of the pair with a value that will + // be invalid as soon as we leave this function... + typename InternalList::Element *new_element = list.push_back(Pair<const K *, V>(&p_key, p_value)); + // ...this is needed here in case the hashmap recursively reference itself... typename InternalMap::Element *e = map.set(p_key, new_element); + // ...now we can set the right value ! new_element->get().first = &e->key(); return Element(new_element); |