diff options
author | Angad Kambli <angadkambli@gmail.com> | 2021-02-17 21:17:57 +0530 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-07-07 16:13:33 +0200 |
commit | 9c6c2f09e07e65f7819920c4954a7fd54b37d3f6 (patch) | |
tree | 718acae86dc3221d813a6a3e69e5bf852b0d14d2 /core/object/object.cpp | |
parent | c3b0a92c3cd9a219c1b1776b48c147f1d0602f07 (diff) | |
download | redot-engine-9c6c2f09e07e65f7819920c4954a7fd54b37d3f6.tar.gz |
Check parameter validity in `Object::set_script`
Fixes #46120.
Diffstat (limited to 'core/object/object.cpp')
-rw-r--r-- | core/object/object.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/core/object/object.cpp b/core/object/object.cpp index c76188a2cd..4d19a2c75b 100644 --- a/core/object/object.cpp +++ b/core/object/object.cpp @@ -836,14 +836,16 @@ void Object::set_script(const Variant &p_script) { return; } + Ref<Script> s = p_script; + ERR_FAIL_COND_MSG(s.is_null() && !p_script.is_null(), "Invalid parameter, it should be a reference to a valid script (or null)."); + + script = p_script; + if (script_instance) { memdelete(script_instance); script_instance = nullptr; } - script = p_script; - Ref<Script> s = script; - if (!s.is_null()) { if (s->can_instantiate()) { OBJ_DEBUG_LOCK |