shithub: qk2

Download patch

ref: 8a0967be5d5789cfaa622818a62d596b3266223e
parent: 36c20e512ee17296b16e79a6010d0deb31e4dcbd
author: qwx <>
date: Sat Dec 15 18:20:09 EST 2018

fix waterline crash

pspan->v can be negative, so s_spanletvars.pz can be set to a bogus address
and crash when read.
underwater view is still broken on weird aspect ratios, but at least it doesn't
crash.

--- a/r_poly.c
+++ b/r_poly.c
@@ -592,7 +592,7 @@
 	do
 	{
 		s_spanletvars.pdest   = (byte *)d_viewbuffer + ( d_scantable[pspan->v] /*r_screenwidth * pspan->v*/) + pspan->u;
-		s_spanletvars.pz      = d_pzbuffer + (d_zwidth * pspan->v) + pspan->u;
+		s_spanletvars.pz      = d_pzbuffer + (d_zwidth * abs(pspan->v)) + pspan->u;
 		s_spanletvars.u       = pspan->u;
 		s_spanletvars.v       = pspan->v;