From d2a22a69608484735b3b436e92f868fef28fa5a4 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 4 Feb 2024 00:59:54 -0800 Subject: [PATCH] R_DrawMaskedColumn: do not draw zero length column - Column would be zero length if there are no visible pixels in it. - Trying to draw such a column results in a negative heightmask in R_DrawColumnTemplate and a probable read out of bounds. --- src/r_things.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index 239ab99a8..a9a13182f 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -685,7 +685,7 @@ void R_DrawMaskedColumn(drawcolumndata_t* dc, column_t *column, column_t *bright if (dc->yh >= baseclip && baseclip != -1) dc->yh = baseclip; - if (dc->yl <= dc->yh && dc->yh > 0) + if (dc->yl <= dc->yh && dc->yh > 0 && column->length != 0) { dc->source = (UINT8 *)column + 3; dc->sourcelength = column->length; @@ -772,7 +772,7 @@ void R_DrawFlippedMaskedColumn(drawcolumndata_t* dc, column_t *column, column_t if (dc->yh >= vid.height) // dc_yl must be < vid.height, so reduces number of checks in tight loop dc->yh = vid.height - 1; - if (dc->yl <= dc->yh && dc->yh > 0) + if (dc->yl <= dc->yh && dc->yh > 0 && column->length != 0) { dc->source = static_cast(ZZ_Alloc(column->length)); dc->sourcelength = column->length;