Small correction on the last commit to avoid an integer overflow

error on large areas (need type dlong to encode areas in internal
units).
This commit is contained in:
Tim Edwards 2019-11-25 16:37:03 -05:00
parent 1fe128a405
commit 46eefe8c33
1 changed files with 7 additions and 1 deletions

View File

@ -1109,6 +1109,7 @@ cifGatherFunc(tile, atotal, mode)
{ {
Tile *tp; Tile *tp;
TileType type; TileType type;
dlong locarea;
Rect area, newarea; Rect area, newarea;
ClientData cdata = (mode == CLOSE_SEARCH) ? (ClientData)CIF_UNPROCESSED : ClientData cdata = (mode == CLOSE_SEARCH) ? (ClientData)CIF_UNPROCESSED :
(ClientData)CIF_PENDING; (ClientData)CIF_PENDING;
@ -1130,7 +1131,12 @@ cifGatherFunc(tile, atotal, mode)
if (mode == CLOSE_SEARCH) if (mode == CLOSE_SEARCH)
{ {
if ((*atotal != INFINITY) && (*atotal < growDistance)) 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) else if (mode == CLOSE_FILL)
{ {