mirror of
https://github.com/godotengine/godot.git
synced 2024-11-27 09:16:35 +08:00
Fixed read-only dictionaries adding missing keys
When querying a non-existing key on a read-only dictionary, the key was still added (albeit never set). This fixes #74726.
This commit is contained in:
parent
d8e242cba8
commit
46e5311d5a
@ -83,7 +83,12 @@ Variant &Dictionary::operator[](const Variant &p_key) {
|
||||
if (unlikely(_p->read_only)) {
|
||||
if (p_key.get_type() == Variant::STRING_NAME) {
|
||||
const StringName *sn = VariantInternal::get_string_name(&p_key);
|
||||
*_p->read_only = _p->variant_map[sn->operator String()];
|
||||
const String &key = sn->operator String();
|
||||
if (_p->variant_map.has(key)) {
|
||||
*_p->read_only = _p->variant_map[key];
|
||||
} else {
|
||||
*_p->read_only = Variant();
|
||||
}
|
||||
} else {
|
||||
*_p->read_only = _p->variant_map[p_key];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user