summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-12-09 14:17:19 +0100
committerGitHub <noreply@github.com>2022-12-09 14:17:19 +0100
commit0f845e25cb7f0f4c91002a03b4c4c679cbb833e0 (patch)
treefd937e85081ab510089e5217a0043df355852e2d /vespalib
parent05b95bef26bec321fba8315739d563c01b830565 (diff)
parenta380225f14314b9cbdeb43376765ac809957d1b6 (diff)
Merge pull request #25187 from vespa-engine/toregge/reduce-probability-for-integer-overflow
Reduce probability for integer overflow.
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/vespa/vespalib/geo/zcurve.cpp2
-rw-r--r--vespalib/src/vespa/vespalib/geo/zcurve.h2
2 files changed, 2 insertions, 2 deletions
diff --git a/vespalib/src/vespa/vespalib/geo/zcurve.cpp b/vespalib/src/vespa/vespalib/geo/zcurve.cpp
index c6a8aa77681..41988276c15 100644
--- a/vespalib/src/vespa/vespalib/geo/zcurve.cpp
+++ b/vespalib/src/vespa/vespalib/geo/zcurve.cpp
@@ -130,7 +130,7 @@ ZCurve::RangeVector
ZCurve::find_ranges(int min_x, int min_y,
int max_x, int max_y)
{
- int64_t total_size = ((max_x - min_x + 1L) * (max_y - min_y + 1L));
+ int64_t total_size = ((static_cast<int64_t>(max_x) - min_x + 1) * (static_cast<int64_t>(max_y) - min_y + 1));
int64_t estimate_target = (total_size * 4);
ZAreaSplitter splitter(min_x, min_y, max_x, max_y);
while (splitter.total_estimate() > estimate_target && splitter.num_ranges() < 42) {
diff --git a/vespalib/src/vespa/vespalib/geo/zcurve.h b/vespalib/src/vespa/vespalib/geo/zcurve.h
index 7830f00733e..ffc39f99266 100644
--- a/vespalib/src/vespa/vespalib/geo/zcurve.h
+++ b/vespalib/src/vespa/vespalib/geo/zcurve.h
@@ -182,7 +182,7 @@ public:
assert((min_y <= max_y) && ((min_y < 0) == (max_y < 0)));
}
Area &operator=(Area &&rhs) { new ((void*)this) Area(rhs); return *this; }
- int64_t size() const { return (max.x - min.x + 1) * (max.y - min.y + 1); }
+ int64_t size() const { return (static_cast<int64_t>(max.x) - min.x + 1) * (static_cast<int64_t>(max.y) - min.y + 1); }
int64_t estimate() const { return (max.z - min.z + 1); }
int64_t error() const { return estimate() - size(); }
};