summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Marques <george@gmarqu.es>2019-11-01 14:37:32 -0300
committerGeorge Marques <george@gmarqu.es>2019-11-01 14:41:52 -0300
commit9fcd38fc70090d2f5eabb2f7effe6a28fa433e9c (patch)
tree42ad4f9844d6ed842604d24291dff6b6b42486b4
parent36a785513fb1424b17c7ae217668f7ca402b5790 (diff)
GDScript: validate instance before accessing it on error
Make sure the instance is valid before trying to access the script in after an error happened. If the instance is not valid it's possible that the script is invalid as well. Fix #29623
-rw-r--r--modules/gdscript/gdscript_function.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/modules/gdscript/gdscript_function.cpp b/modules/gdscript/gdscript_function.cpp
index 83d02e4977..d8816726ce 100644
--- a/modules/gdscript/gdscript_function.cpp
+++ b/modules/gdscript/gdscript_function.cpp
@@ -1561,14 +1561,14 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
//error
// function, file, line, error, explanation
String err_file;
- if (p_instance && p_instance->script->is_valid() && p_instance->script->path != "")
+ if (p_instance && ObjectDB::instance_validate(p_instance->owner) && p_instance->script->is_valid() && p_instance->script->path != "")
err_file = p_instance->script->path;
else if (script)
err_file = script->path;
if (err_file == "")
err_file = "<built-in>";
String err_func = name;
- if (p_instance && p_instance->script->is_valid() && p_instance->script->name != "")
+ if (p_instance && ObjectDB::instance_validate(p_instance->owner) && p_instance->script->is_valid() && p_instance->script->name != "")
err_func = p_instance->script->name + "." + err_func;
int err_line = line;
if (err_text == "") {