Skip to content

Commit a72262f

Browse files
ClaasJGmicycle1
authored andcommitted
Fix mutation of global state 'InvalidRect64'/'InvalidRectD'
by 'GetBounds' variants.
1 parent 706ae87 commit a72262f

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/main/java/clipper2/Clipper.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ public static PathsD ReversePaths(PathsD paths) {
677677
}
678678

679679
public static Rect64 GetBounds(Path64 path) {
680-
Rect64 result = InvalidRect64;
680+
Rect64 result = InvalidRect64.clone();
681681
for (Point64 pt : path) {
682682
if (pt.x < result.left) {
683683
result.left = pt.x;
@@ -696,7 +696,7 @@ public static Rect64 GetBounds(Path64 path) {
696696
}
697697

698698
public static Rect64 GetBounds(Paths64 paths) {
699-
Rect64 result = InvalidRect64;
699+
Rect64 result = InvalidRect64.clone();
700700
for (Path64 path : paths) {
701701
for (Point64 pt : path) {
702702
if (pt.x < result.left) {
@@ -717,7 +717,7 @@ public static Rect64 GetBounds(Paths64 paths) {
717717
}
718718

719719
public static RectD GetBounds(PathD path) {
720-
RectD result = InvalidRectD;
720+
RectD result = InvalidRectD.clone();
721721
for (PointD pt : path) {
722722
if (pt.x < result.left) {
723723
result.left = pt.x;
@@ -736,7 +736,7 @@ public static RectD GetBounds(PathD path) {
736736
}
737737

738738
public static RectD GetBounds(PathsD paths) {
739-
RectD result = InvalidRectD;
739+
RectD result = InvalidRectD.clone();
740740
for (PathD path : paths) {
741741
for (PointD pt : path) {
742742
if (pt.x < result.left) {

src/main/java/clipper2/engine/ClipperBase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2778,7 +2778,7 @@ public static Rect64 GetBounds(Path64 path) {
27782778
if (path.isEmpty()) {
27792779
return new Rect64();
27802780
}
2781-
Rect64 result = Clipper.InvalidRect64;
2781+
Rect64 result = Clipper.InvalidRect64.clone();
27822782
for (Point64 pt : path) {
27832783
if (pt.x < result.left) {
27842784
result.left = pt.x;
@@ -2893,7 +2893,7 @@ protected void BuildTree(PolyPathBase polytree, Paths64 solutionOpen) {
28932893
}
28942894

28952895
public final Rect64 GetBounds() {
2896-
Rect64 bounds = Clipper.InvalidRect64;
2896+
Rect64 bounds = Clipper.InvalidRect64.clone();
28972897
for (Vertex t : vertexList) {
28982898
Vertex v = t;
28992899
do {

0 commit comments

Comments
 (0)