mirror of
https://github.com/godotengine/godot.git
synced 2024-12-16 16:13:56 +00:00
Merge pull request #34958 from vnen/gdscript-is-check-valid-instance
GDScript: Validate object instance on `is` operation
This commit is contained in:
commit
09aa12a0dd
@ -803,6 +803,18 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
|
||||
}
|
||||
} break;
|
||||
case Variant::OBJECT: {
|
||||
#ifdef DEBUG_ENABLED
|
||||
// Test for potential wrong values sent by the debugger when it breaks.
|
||||
Object *obj = p_variant;
|
||||
if (!obj || !ObjectDB::instance_validate(obj)) {
|
||||
// Object is invalid, send a NULL instead.
|
||||
if (buf) {
|
||||
encode_uint32(Variant::NIL, buf);
|
||||
}
|
||||
r_len += 4;
|
||||
return OK;
|
||||
}
|
||||
#endif // DEBUG_ENABLED
|
||||
if (!p_full_objects) {
|
||||
flags |= ENCODE_FLAG_OBJECT_AS_ID;
|
||||
}
|
||||
|
@ -500,6 +500,13 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
||||
Object *obj_A = *a;
|
||||
Object *obj_B = *b;
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (!ObjectDB::instance_validate(obj_A)) {
|
||||
err_text = "Left operand of 'is' was already freed.";
|
||||
OPCODE_BREAK;
|
||||
}
|
||||
#endif // DEBUG_ENABLED
|
||||
|
||||
GDScript *scr_B = Object::cast_to<GDScript>(obj_B);
|
||||
|
||||
if (scr_B) {
|
||||
|
Loading…
Reference in New Issue
Block a user