From 0d8254172890eec3af5ef83c952660faede04f8d Mon Sep 17 00:00:00 2001 From: Tom Poole Date: Thu, 17 Mar 2022 11:34:32 +0000 Subject: [PATCH] Point: Fix a division by zero in getPointAlongLine --- modules/juce_graphics/geometry/juce_Line.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/juce_graphics/geometry/juce_Line.h b/modules/juce_graphics/geometry/juce_Line.h index ad258e5fa9..b938d07728 100644 --- a/modules/juce_graphics/geometry/juce_Line.h +++ b/modules/juce_graphics/geometry/juce_Line.h @@ -203,7 +203,8 @@ public: */ Point getPointAlongLine (ValueType distanceFromStart) const noexcept { - return start + (end - start) * (distanceFromStart / getLength()); + const auto length = getLength(); + return length == 0 ? start : start + (end - start) * (distanceFromStart / length); } /** Returns a point which is a certain distance along and to the side of this line.