Corrected an error in the "close" CIF operator, which was checking

for infinities in space tiles by checking tile dimensions against
TiPlaneRect, where in fact TiPlaneRect is slightly smaller than
the plane boundaries, so this check would always fail, causing
unpredictable behavior due to integer overflow.
This commit is contained in:
Tim Edwards 2020-11-24 15:57:40 -05:00
parent 497c13c34e
commit 83e2fe55ce
1 changed files with 5 additions and 4 deletions

View File

@ -1972,11 +1972,12 @@ cifGatherFunc(tile, atotal, mode)
TiToRect(tile, &area);
/* Boundary tiles indicate an unclosed area, so set the area total to */
/* INFINITY and don't try to run calculations on it. */
/* Boundary tiles indicate an unclosed area, so set the area total to */
/* INFINITY and don't try to run calculations on it. NOTE: TiPlaneRect */
/* is slightly smaller than the plane boundaries on all sides. */
if ((area.r_xbot == TiPlaneRect.r_xbot) || (area.r_ybot == TiPlaneRect.r_ybot) ||
(area.r_xtop == TiPlaneRect.r_xtop) || (area.r_ytop == TiPlaneRect.r_ytop))
if ((area.r_xbot <= TiPlaneRect.r_xbot) || (area.r_ybot <= TiPlaneRect.r_ybot) ||
(area.r_xtop >= TiPlaneRect.r_xtop) || (area.r_ytop >= TiPlaneRect.r_ytop))
*atotal = INFINITY;
/* Stop accumulating if already larger than growDistance to avoid the */