Skip to content

Commit

Permalink
Fixed an integer overflow error in ClipperOffset (#867)
Browse files Browse the repository at this point in the history
  • Loading branch information
AngusJohnson committed Jul 13, 2024
1 parent 4240912 commit 68b3a2c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions CSharp/Clipper2Lib/Clipper.Offset.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* Author : Angus Johnson *
* Date : 17 April 2024 *
* Date : 13 July 2024 *
* Website : http://www.angusj.com *
* Copyright : Angus Johnson 2010-2024 *
* Purpose : Path Offset (Inflate/Shrink) *
Expand Down Expand Up @@ -513,8 +513,8 @@ private void BuildNormals(Path64 path)
{
int cnt = path.Count;
_normals.Clear();
if (cnt == 0) return;
_normals.EnsureCapacity(cnt);

for (int i = 0; i < cnt - 1; i++)
_normals.Add(GetUnitNormal(path[i], path[i + 1]));
_normals.Add(GetUnitNormal(path[cnt - 1], path[0]));
Expand Down
6 changes: 2 additions & 4 deletions Delphi/Clipper2Lib/Clipper.Offset.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

(*******************************************************************************
* Author : Angus Johnson *
* Date : 17 April 2024 *
* Date : 6 July 2024 *
* Website : http://www.angusj.com *
* Copyright : Angus Johnson 2010-2024 *
* Purpose : Path Offset (Inflate/Shrink) *
Expand Down Expand Up @@ -236,9 +236,7 @@ function UnsafeGet(List: TList; Index: Integer): Pointer;
constructor TGroup.Create(const pathsIn: TPaths64; jt: TJoinType; et: TEndType);
var
i, len: integer;
a: double;
isJoined: boolean;
pb: PBoolean;
begin
Self.joinType := jt;
Self.endType := et;
Expand Down Expand Up @@ -345,7 +343,6 @@ procedure TClipperOffset.DoGroupOffset(group: TGroup);
i,j, len, steps: Integer;
r, stepsPer360, arcTol: Double;
absDelta: double;
isShrinking: Boolean;
rec: TRect64;
pt0: TPoint64;
begin
Expand Down Expand Up @@ -450,6 +447,7 @@ procedure TClipperOffset.BuildNormals;
begin
len := Length(fInPath);
SetLength(fNorms, len);
if len = 0 then Exit;
for i := 0 to len-2 do
fNorms[i] := GetUnitNormal(fInPath[i], fInPath[i+1]);
fNorms[len -1] := GetUnitNormal(fInPath[len -1], fInPath[0]);
Expand Down

0 comments on commit 68b3a2c

Please sign in to comment.