Sfoglia il codice sorgente

Merge pull request #47576 from jmb462/fix-classDB-class_get_property-crash

Fix crash on null object in ClassDB.get_property() and set_property() (Fix #47573)
Rémi Verschelde 4 anni fa
parent
commit
9859f6d147
1 ha cambiato i file con 4 aggiunte e 0 eliminazioni
  1. 4 0
      core/object/class_db.cpp

+ 4 - 0
core/object/class_db.cpp

@@ -1095,6 +1095,8 @@ bool ClassDB::get_property_info(StringName p_class, StringName p_property, Prope
 }
 }
 
 
 bool ClassDB::set_property(Object *p_object, const StringName &p_property, const Variant &p_value, bool *r_valid) {
 bool ClassDB::set_property(Object *p_object, const StringName &p_property, const Variant &p_value, bool *r_valid) {
+	ERR_FAIL_NULL_V(p_object, false);
+
 	ClassInfo *type = classes.getptr(p_object->get_class_name());
 	ClassInfo *type = classes.getptr(p_object->get_class_name());
 	ClassInfo *check = type;
 	ClassInfo *check = type;
 	while (check) {
 	while (check) {
@@ -1142,6 +1144,8 @@ bool ClassDB::set_property(Object *p_object, const StringName &p_property, const
 }
 }
 
 
 bool ClassDB::get_property(Object *p_object, const StringName &p_property, Variant &r_value) {
 bool ClassDB::get_property(Object *p_object, const StringName &p_property, Variant &r_value) {
+	ERR_FAIL_NULL_V(p_object, false);
+
 	ClassInfo *type = classes.getptr(p_object->get_class_name());
 	ClassInfo *type = classes.getptr(p_object->get_class_name());
 	ClassInfo *check = type;
 	ClassInfo *check = type;
 	while (check) {
 	while (check) {