Merge pull request #46125 from angad-k/fix-object-to-check-script-pointer-validity

Check parameter validity in `Object::set_script`
This commit is contained in:
Rémi Verschelde 2023-07-08 18:14:17 +02:00
commit 7e39c91508
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -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