summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/variant/dictionary.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/core/variant/dictionary.cpp b/core/variant/dictionary.cpp
index 0429508cc5..7ab150a4f8 100644
--- a/core/variant/dictionary.cpp
+++ b/core/variant/dictionary.cpp
@@ -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];
}