Skip to content

Commit 68b3a2c

Browse files
committed
Fixed an integer overflow error in ClipperOffset (#867)
1 parent 4240912 commit 68b3a2c

2 files changed

Lines changed: 4 additions & 6 deletions

File tree

CSharp/Clipper2Lib/Clipper.Offset.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*******************************************************************************
22
* Author : Angus Johnson *
3-
* Date : 17 April 2024 *
3+
* Date : 13 July 2024 *
44
* Website : http://www.angusj.com *
55
* Copyright : Angus Johnson 2010-2024 *
66
* Purpose : Path Offset (Inflate/Shrink) *
@@ -513,8 +513,8 @@ private void BuildNormals(Path64 path)
513513
{
514514
int cnt = path.Count;
515515
_normals.Clear();
516+
if (cnt == 0) return;
516517
_normals.EnsureCapacity(cnt);
517-
518518
for (int i = 0; i < cnt - 1; i++)
519519
_normals.Add(GetUnitNormal(path[i], path[i + 1]));
520520
_normals.Add(GetUnitNormal(path[cnt - 1], path[0]));

Delphi/Clipper2Lib/Clipper.Offset.pas

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
(*******************************************************************************
44
* Author : Angus Johnson *
5-
* Date : 17 April 2024 *
5+
* Date : 6 July 2024 *
66
* Website : http://www.angusj.com *
77
* Copyright : Angus Johnson 2010-2024 *
88
* Purpose : Path Offset (Inflate/Shrink) *
@@ -236,9 +236,7 @@ function UnsafeGet(List: TList; Index: Integer): Pointer;
236236
constructor TGroup.Create(const pathsIn: TPaths64; jt: TJoinType; et: TEndType);
237237
var
238238
i, len: integer;
239-
a: double;
240239
isJoined: boolean;
241-
pb: PBoolean;
242240
begin
243241
Self.joinType := jt;
244242
Self.endType := et;
@@ -345,7 +343,6 @@ procedure TClipperOffset.DoGroupOffset(group: TGroup);
345343
i,j, len, steps: Integer;
346344
r, stepsPer360, arcTol: Double;
347345
absDelta: double;
348-
isShrinking: Boolean;
349346
rec: TRect64;
350347
pt0: TPoint64;
351348
begin
@@ -450,6 +447,7 @@ procedure TClipperOffset.BuildNormals;
450447
begin
451448
len := Length(fInPath);
452449
SetLength(fNorms, len);
450+
if len = 0 then Exit;
453451
for i := 0 to len-2 do
454452
fNorms[i] := GetUnitNormal(fInPath[i], fInPath[i+1]);
455453
fNorms[len -1] := GetUnitNormal(fInPath[len -1], fInPath[0]);

0 commit comments

Comments
 (0)