d3drm: Fix vertex index test and print a warning when it is out of range.

This commit is contained in:
Christian Costa 2012-06-08 15:38:25 +02:00 committed by Alexandre Julliard
parent e80d6199dc
commit 422d57e7d2
1 changed files with 4 additions and 1 deletions

View File

@ -1366,8 +1366,11 @@ HRESULT load_mesh_data(IDirect3DRMMeshBuilder3* iface, LPDIRECTXFILEDATA pData)
else
{
DWORD vertex_idx = *faces_vertex_idx_ptr;
if (vertex_idx > This->nb_vertices)
if (vertex_idx >= This->nb_vertices)
{
WARN("Found vertex index %u but only %u vertices available => use index 0\n", vertex_idx, This->nb_vertices);
vertex_idx = 0;
}
*(faces_data_ptr + faces_data_size++) = vertex_idx;
/* Add face normal to vertex normal */
D3DRMVectorAdd(&This->pNormals[vertex_idx], &This->pNormals[vertex_idx], &face_normal);