From 46eefe8c33ef35ef4ae7fe66b72e4d3a67acac51 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Mon, 25 Nov 2019 16:37:03 -0500 Subject: [PATCH] Small correction on the last commit to avoid an integer overflow error on large areas (need type dlong to encode areas in internal units). --- cif/CIFgen.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cif/CIFgen.c b/cif/CIFgen.c index 1316f1fd..4381742b 100644 --- a/cif/CIFgen.c +++ b/cif/CIFgen.c @@ -1109,6 +1109,7 @@ cifGatherFunc(tile, atotal, mode) { Tile *tp; TileType type; + dlong locarea; Rect area, newarea; ClientData cdata = (mode == CLOSE_SEARCH) ? (ClientData)CIF_UNPROCESSED : (ClientData)CIF_PENDING; @@ -1130,7 +1131,12 @@ cifGatherFunc(tile, atotal, mode) if (mode == CLOSE_SEARCH) { if ((*atotal != INFINITY) && (*atotal < growDistance)) - *atotal += (area.r_xtop - area.r_xbot) * (area.r_ytop - area.r_ybot); + locarea = (dlong)(area.r_xtop - area.r_xbot) + * (dlong)(area.r_ytop - area.r_ybot); + if (locarea > (dlong)INFINITY) + *atotal = INFINITY; + else + *atotal += (int)locarea; } else if (mode == CLOSE_FILL) {