]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
meshentities: don't pass a NULL ptr to memset
authorbones_was_here <bones_was_here@xonotic.au>
Fri, 26 Jan 2024 08:29:54 +0000 (18:29 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Mon, 29 Jan 2024 15:32:56 +0000 (01:32 +1000)
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
model_shared.c

index 866ee56ee5a2c2332f2fe213aad1753e6b95ec80..c83ece29211695913750cff4b0b43c9fee98ad2c 100644 (file)
@@ -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
 }