From: bones_was_here Date: Fri, 26 Jan 2024 08:29:54 +0000 (+1000) Subject: meshentities: don't pass a NULL ptr to memset X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=725fd6f84346fc1b35cdc0e5637aee9c2fde4063;p=xonotic%2Fdarkplaces.git meshentities: don't pass a NULL ptr to memset Signed-off-by: bones_was_here --- diff --git a/model_shared.c b/model_shared.c index 866ee56e..c83ece29 100644 --- a/model_shared.c +++ b/model_shared.c @@ -4467,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 }