Skip to content

Commit

Permalink
Add a check in R_CheckPlane to prevent stack trashing
Browse files Browse the repository at this point in the history
Fixes illegal memory writes and freezes that may happen when there's an overrun due to when there's an excessively large number of visplanes added to the visplanes array
  • Loading branch information
AXDOOMER committed Nov 20, 2018
1 parent 194d0d0 commit 56ccf3a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions r_plane.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,10 @@ R_CheckPlane
lastvisplane->picnum = pl->picnum;
lastvisplane->lightlevel = pl->lightlevel;

// fix: prevent the stack from being trashed
if (lastvisplane - visplanes == MAXVISPLANES)
I_Error ("R_CheckPlane: no more visplanes");

pl = lastvisplane++;
pl->minx = start;
pl->maxx = stop;
Expand Down

0 comments on commit 56ccf3a

Please sign in to comment.