games/NXDoom: Check visplane capacity before writing.

Move the maximum-visplane guard ahead of the new plane initialization. At full capacity, the previous ordering wrote three fields one element past the visplanes array before reporting the overflow.

Assisted-by: Codex:gpt-5
Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>
This commit is contained in:
aviralgarg05 2026-07-23 21:12:45 +05:30
parent c4bf636057
commit 8bfd83c401

View file

@ -451,13 +451,15 @@ visplane_t *r_check_plane(visplane_t *pl, int start, int stop)
/* make a new visplane */
if (lastvisplane - visplanes == CONFIG_GAMES_NXDOOM_MAXVISPLANES)
{
i_error("r_check_plane: no more visplanes");
}
lastvisplane->height = pl->height;
lastvisplane->picnum = pl->picnum;
lastvisplane->lightlevel = pl->lightlevel;
if (lastvisplane - visplanes == CONFIG_GAMES_NXDOOM_MAXVISPLANES)
i_error("r_check_plane: no more visplanes");
pl = lastvisplane++;
pl->minx = start;
pl->maxx = stop;