From 72bd3e28ed2471daad12125b014d90d2bb300a86 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 31 Jan 2017 22:10:31 +0000 Subject: [PATCH] Fix sprtopscreen from getting integer overflows once and for all in R_DrawRepeatMaskedColumn Fixes TD's terminal from freezing the game this time, oh boy --- src/r_segs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/r_segs.c b/src/r_segs.c index 3059860c..502ff330 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -708,7 +708,10 @@ static void R_DrawRepeatMaskedColumn(column_t *col) { while (sprtopscreen < sprbotscreen) { R_DrawMaskedColumn(col); - sprtopscreen += dc_texheight*spryscale; + if ((INT64)sprtopscreen + dc_texheight*spryscale > (INT64)INT32_MAX) // prevent overflow + sprtopscreen = INT32_MAX; + else + sprtopscreen += dc_texheight*spryscale; } }