Skip to content

Commit

Permalink
Check parameter validity in Object::set_script
Browse files Browse the repository at this point in the history
Fixes godotengine#46120.

(cherry picked from commit 9c6c2f0)
  • Loading branch information
angad-k authored and YuriSizov committed Jul 10, 2023
1 parent 4c1c269 commit cdeddff
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions core/object/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cdeddff

Please sign in to comment.