1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-04 13:42:55 +01:00

Fix #5205: Prevent the paint loop becoming an infinite loop (#5771)

This commit is contained in:
Tomas Dittmann
2017-07-05 19:00:30 +02:00
committed by Ted John
parent ee58ac4882
commit 14d14de911

View File

@@ -707,8 +707,12 @@ void viewport_paint(rct_viewport* viewport, rct_drawpixelinfo* dpi, sint16 left,
dpi1.pitch = (dpi->width + dpi->pitch) - (width >> viewport->zoom);
dpi1.zoom_level = viewport->zoom;
// make sure, the compare operation is done in sint16 to avoid the loop becoming an infiniteloop.
// this as well as the [x += 32] in the loop causes signed integer overflow -> undefined behaviour.
sint16 rightBorder = dpi1.x + dpi1.width;
// Splits the area into 32 pixel columns and renders them
for (x = floor2(dpi1.x, 32); x < dpi1.x + dpi1.width; x += 32) {
for (x = floor2(dpi1.x, 32); x < rightBorder; x += 32) {
rct_drawpixelinfo dpi2 = dpi1;
if (x >= dpi2.x) {
sint16 leftPitch = x - dpi2.x;