From 42ee315b6061c44e58609ae84de9af4b7ab85f19 Mon Sep 17 00:00:00 2001 From: Aras Pranckevicius Date: Thu, 2 Nov 2023 21:35:02 +0200 Subject: [PATCH] Fix #114304: OBJ import crash when some faces have normals, and others do not The file that reproduces this had some faces of a mesh with vertex normals, while some other faces were without vertex normals. The parsing code assigns INT32_MAX as a fallback of "I could not parse the normal index as a number" case, but later on code was not catching this "normal index might be invalid" case. Fixes #114304 --- source/blender/io/wavefront_obj/importer/obj_import_mesh.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc b/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc index 5a602cd3521..b243847b064 100644 --- a/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc +++ b/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc @@ -377,7 +377,7 @@ void MeshFromGeometry::create_normals(Mesh *mesh) const PolyCorner &curr_corner = mesh_geometry_.face_corners_[curr_face.start_index_ + idx]; int n_index = curr_corner.vertex_normal_index; float3 normal(0, 0, 0); - if (n_index >= 0) { + if (n_index >= 0 && n_index < global_vertices_.vert_normals.size()) { normal = global_vertices_.vert_normals[n_index]; } copy_v3_v3(loop_normals[tot_loop_idx], normal);