Merge branch 'misc-sanitize' into 'master'

Misc fixes for memory errors revealed by -fsanitize=address

See merge request KartKrew/Kart!1143
This commit is contained in:
toaster 2023-04-05 11:40:45 +00:00
commit a97f53874e
5 changed files with 10 additions and 4 deletions

View file

@ -4011,7 +4011,7 @@ void M_DrawPause(void)
i++; // Regardless of whether we drew or not, go to the next item in the menu.
if (i > currentMenu->numitems)
if (i >= currentMenu->numitems)
{
i = 0;
while (!(currentMenu->menuitems[i].status & IT_DISPLAY))

View file

@ -782,12 +782,13 @@ static void M_CreateScreenShotPalette(void)
#if NUMSCREENS > 2
static const char *Newsnapshotfile(const char *pathname, const char *ext)
{
static char freename[19] = "ringracersXXXX.ext";
static char freename[20] = "ringracersXXXX.exte";
int i = 5000; // start in the middle: num screenshots divided by 2
int add = i; // how much to add or subtract if wrong; gets divided by 2 each time
int result; // -1 = guess too high, 0 = correct, 1 = guess too low
// find a file name to save it to
I_Assert(strlen(ext) < (sizeof freename) - 15);
strcpy(freename+15,ext);
for (;;)

View file

@ -1451,7 +1451,8 @@ static void R_RenderSegLoop (void)
//SoM: Calculate offsets for Thick fake floors.
// calculate texture offset
angle = (rw_centerangle + xtoviewangle[viewssnum][rw_x])>>ANGLETOFINESHIFT;
texturecolumn = rw_offset-FixedMul(FINETANGENT(angle),rw_distance);
// Mask 4095 to guarantee this index is within bounds
texturecolumn = rw_offset-FixedMul(FINETANGENT(angle & 4095),rw_distance);
if (oldtexturecolumn != -1) {
rw_bottomtexturemid += FixedMul(rw_bottomtextureslide, oldtexturecolumn-texturecolumn);

View file

@ -425,6 +425,8 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr
ds_colormap = vis->colormap;
ds_fullbright = colormaps;
ds_brightmap = NULL;
ds_translation = R_GetSpriteTranslation(vis);
if (ds_translation == NULL)
ds_translation = colormaps;

View file

@ -438,8 +438,10 @@ void ST_drawDebugInfo(void)
{
INT32 height = 192;
const UINT8 screen = cv_devmode_screen.value - 1;
// devmode_screen = 1..4
stplyr = &players[displayplayers[min(r_splitscreen, cv_devmode_screen.value - 1)]];
stplyr = &players[displayplayers[min(r_splitscreen, screen)]];
if (!stplyr->mo)
return;