From a72262f28b05ad5f45e1f27d243d78d0585c512f Mon Sep 17 00:00:00 2001 From: "Claas j. Gramann" Date: Sun, 22 Oct 2023 17:16:24 +0200 Subject: [PATCH] Fix mutation of global state 'InvalidRect64'/'InvalidRectD' by 'GetBounds' variants. --- src/main/java/clipper2/Clipper.java | 8 ++++---- src/main/java/clipper2/engine/ClipperBase.java | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/clipper2/Clipper.java b/src/main/java/clipper2/Clipper.java index 45302ca..6e9982b 100644 --- a/src/main/java/clipper2/Clipper.java +++ b/src/main/java/clipper2/Clipper.java @@ -677,7 +677,7 @@ public static PathsD ReversePaths(PathsD paths) { } public static Rect64 GetBounds(Path64 path) { - Rect64 result = InvalidRect64; + Rect64 result = InvalidRect64.clone(); for (Point64 pt : path) { if (pt.x < result.left) { result.left = pt.x; @@ -696,7 +696,7 @@ public static Rect64 GetBounds(Path64 path) { } public static Rect64 GetBounds(Paths64 paths) { - Rect64 result = InvalidRect64; + Rect64 result = InvalidRect64.clone(); for (Path64 path : paths) { for (Point64 pt : path) { if (pt.x < result.left) { @@ -717,7 +717,7 @@ public static Rect64 GetBounds(Paths64 paths) { } public static RectD GetBounds(PathD path) { - RectD result = InvalidRectD; + RectD result = InvalidRectD.clone(); for (PointD pt : path) { if (pt.x < result.left) { result.left = pt.x; @@ -736,7 +736,7 @@ public static RectD GetBounds(PathD path) { } public static RectD GetBounds(PathsD paths) { - RectD result = InvalidRectD; + RectD result = InvalidRectD.clone(); for (PathD path : paths) { for (PointD pt : path) { if (pt.x < result.left) { diff --git a/src/main/java/clipper2/engine/ClipperBase.java b/src/main/java/clipper2/engine/ClipperBase.java index d57e33f..626d28e 100644 --- a/src/main/java/clipper2/engine/ClipperBase.java +++ b/src/main/java/clipper2/engine/ClipperBase.java @@ -2778,7 +2778,7 @@ public static Rect64 GetBounds(Path64 path) { if (path.isEmpty()) { return new Rect64(); } - Rect64 result = Clipper.InvalidRect64; + Rect64 result = Clipper.InvalidRect64.clone(); for (Point64 pt : path) { if (pt.x < result.left) { result.left = pt.x; @@ -2893,7 +2893,7 @@ protected void BuildTree(PolyPathBase polytree, Paths64 solutionOpen) { } public final Rect64 GetBounds() { - Rect64 bounds = Clipper.InvalidRect64; + Rect64 bounds = Clipper.InvalidRect64.clone(); for (Vertex t : vertexList) { Vertex v = t; do {