Codechange: address CodeQL issue "Multiplication result converted to larger type" (#10306)
Most are very unlikely to ever be triggered in our codebase; two stand out: linkgraph and money cheat. Those, potentially, could wrap earlier than expected.
This commit is contained in:
@@ -1126,7 +1126,7 @@ void GetStationLayout(byte *layout, uint numtracks, uint plat_len, const Station
|
||||
!statspec->layouts[plat_len - 1][numtracks - 1].empty()) {
|
||||
/* Custom layout defined, follow it. */
|
||||
memcpy(layout, statspec->layouts[plat_len - 1][numtracks - 1].data(),
|
||||
plat_len * numtracks);
|
||||
static_cast<size_t>(plat_len) * numtracks);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1864,7 +1864,7 @@ CommandCost CmdBuildRoadStop(DoCommandFlag flags, TileIndex tile, uint8 width, u
|
||||
if (ret.Failed()) return ret;
|
||||
|
||||
/* Check if this number of road stops can be allocated. */
|
||||
if (!RoadStop::CanAllocateItem(roadstop_area.w * roadstop_area.h)) return_cmd_error(is_truck_stop ? STR_ERROR_TOO_MANY_TRUCK_STOPS : STR_ERROR_TOO_MANY_BUS_STOPS);
|
||||
if (!RoadStop::CanAllocateItem(static_cast<size_t>(roadstop_area.w) * roadstop_area.h)) return_cmd_error(is_truck_stop ? STR_ERROR_TOO_MANY_TRUCK_STOPS : STR_ERROR_TOO_MANY_BUS_STOPS);
|
||||
|
||||
ret = BuildStationPart(&st, flags, reuse, roadstop_area, STATIONNAMING_ROAD);
|
||||
if (ret.Failed()) return ret;
|
||||
|
Reference in New Issue
Block a user