From c86f06caa0be207882266947da67125177bba5af Mon Sep 17 00:00:00 2001 From: dann-merlin <55287004+dann-merlin@users.noreply.github.com> Date: Sun, 16 Apr 2023 00:27:14 +0000 Subject: [PATCH] Fix possible usage of clamp with lo > hi in Vector2D (#2049) --- src/helpers/Vector2D.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/Vector2D.cpp b/src/helpers/Vector2D.cpp index afd8b22a..2baa7353 100644 --- a/src/helpers/Vector2D.cpp +++ b/src/helpers/Vector2D.cpp @@ -29,7 +29,7 @@ Vector2D Vector2D::floor() { } Vector2D Vector2D::clamp(const Vector2D& min, const Vector2D& max) { - return Vector2D(std::clamp(this->x, min.x, max.x == 0 ? INFINITY : max.x), std::clamp(this->y, min.y, max.y == 0 ? INFINITY : max.y)); + return Vector2D(std::clamp(this->x, min.x, max.x < min.x ? INFINITY : max.x), std::clamp(this->y, min.y, max.y < min.y ? INFINITY : max.y)); } double Vector2D::distance(const Vector2D& other) {