From 83e2fe55ce2d66de1fba63ae923f0e2614da7fe8 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Tue, 24 Nov 2020 15:57:40 -0500 Subject: [PATCH] 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. --- cif/CIFgen.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cif/CIFgen.c b/cif/CIFgen.c index e04a2769..f5c4038f 100644 --- a/cif/CIFgen.c +++ b/cif/CIFgen.c @@ -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 */