Fix UBSan Warnings

- memcpy() shouldn't be called with NULL, even if length == 0
- In CMod_LoadBrushSides() j (from in->texinfo) could be -1,
  which of course is no valid array index
This commit is contained in:
Daniel Gibson 2021-06-04 13:39:43 +02:00
parent dc7ad65bb0
commit 7ae9655f3a
2 changed files with 3 additions and 2 deletions

View file

@ -1532,7 +1532,7 @@ CMod_LoadBrushSides(lump_t *l)
Com_Error(ERR_DROP, "Bad brushside texinfo");
}
out->surface = &map_surfaces[j];
out->surface = (j >= 0) ? &map_surfaces[j] : &nullsurface;
}
}

View file

@ -73,7 +73,8 @@ SZ_GetSpace(sizebuf_t *buf, int length)
void
SZ_Write(sizebuf_t *buf, void *data, int length)
{
memcpy(SZ_GetSpace(buf, length), data, length);
if(length > 0)
memcpy(SZ_GetSpace(buf, length), data, length);
}
void