Browse Source

Merge pull request #57168 from pfertyk/issue-57130-fix-generate-scene-if-state-is-null

Fix `GLTFDocument.generate_scene` crash with invalid state
Rémi Verschelde 3 years ago
parent
commit
1991eae992
1 changed files with 1 additions and 0 deletions
  1. 1 0
      modules/gltf/gltf_document.cpp

+ 1 - 0
modules/gltf/gltf_document.cpp

@@ -6843,6 +6843,7 @@ Error GLTFDocument::write_to_filesystem(Ref<GLTFState> state, const String &p_pa
 }
 }
 
 
 Node *GLTFDocument::generate_scene(Ref<GLTFState> state, int32_t p_bake_fps) {
 Node *GLTFDocument::generate_scene(Ref<GLTFState> state, int32_t p_bake_fps) {
+	ERR_FAIL_NULL_V(state, nullptr);
 	ERR_FAIL_INDEX_V(0, state->root_nodes.size(), nullptr);
 	ERR_FAIL_INDEX_V(0, state->root_nodes.size(), nullptr);
 	GLTFNodeIndex gltf_root = state->root_nodes.write[0];
 	GLTFNodeIndex gltf_root = state->root_nodes.write[0];
 	Node *gltf_root_node = state->get_scene_node(gltf_root);
 	Node *gltf_root_node = state->get_scene_node(gltf_root);