X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=model_shared.c;h=d6cea915396455ffce1b181e5ed6a0f99018af31;hb=HEAD;hp=fd181f355685198e8b6aea6815380855d2606bce;hpb=591877ee0c64958303dcbb4f2af3d343a420cf6a;p=xonotic%2Fdarkplaces.git diff --git a/model_shared.c b/model_shared.c index fd181f35..adf8a867 100644 --- a/model_shared.c +++ b/model_shared.c @@ -550,7 +550,7 @@ model_t *Mod_LoadModel(model_t *mod, qbool crash, qbool checkdisk) Con_Printf(CON_ERROR "Mod_LoadModel: model \"%s\" is of unknown/unsupported type\n", mod->name); } else if (crash) - // LadyHavoc: Sys_Abort was *ANNOYING* + // LadyHavoc: Sys_Error was *ANNOYING* Con_Printf (CON_ERROR "Mod_LoadModel: %s not found\n", mod->name); // no fatal errors occurred, so this model is ready to use. @@ -1044,6 +1044,12 @@ void Mod_ShadowMesh_AddMesh(shadowmesh_t *mesh, const float *vertex3f, int numtr for (i = 0;i < numtris;i++) { + if ((mesh->numtriangles * 3 + 2) * sizeof(int) + 1 >= Mem_Size(mesh->element3i)) + { + // FIXME: we didn't allocate enough space for all the tris, see R_Mod_CompileShadowMap + Con_Print(CON_WARN "Mod_ShadowMesh_AddMesh: insufficient memory allocated!\n"); + return; + } mesh->element3i[mesh->numtriangles * 3 + 0] = Mod_ShadowMesh_AddVertex(mesh, vertex3f + 3 * element3i[i * 3 + 0]); mesh->element3i[mesh->numtriangles * 3 + 1] = Mod_ShadowMesh_AddVertex(mesh, vertex3f + 3 * element3i[i * 3 + 1]); mesh->element3i[mesh->numtriangles * 3 + 2] = Mod_ShadowMesh_AddVertex(mesh, vertex3f + 3 * element3i[i * 3 + 2]); @@ -4461,7 +4467,8 @@ void Mod_Mesh_Reset(model_t *mod) mod->num_surfaces = 0; mod->surfmesh.num_vertices = 0; mod->surfmesh.num_triangles = 0; - memset(mod->surfmesh.data_vertexhash, -1, mod->surfmesh.num_vertexhashsize * sizeof(*mod->surfmesh.data_vertexhash)); + if (mod->surfmesh.data_vertexhash) // UBSan: memset arg 1 isn't allowed to be null, but sometimes this is NULL. + memset(mod->surfmesh.data_vertexhash, -1, mod->surfmesh.num_vertexhashsize * sizeof(*mod->surfmesh.data_vertexhash)); mod->DrawSky = NULL; // will be set if a texture needs it mod->DrawAddWaterPlanes = NULL; // will be set if a texture needs it }