Skip to content

Commit 7fb7fe0

Browse files
committed
protect against possible trap
1 parent 107eaee commit 7fb7fe0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

SwiftDraw/LayerTree.Builder.Path.Arc.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,10 @@ func makeCubic(from origin: LayerTree.Point, to destination: LayerTree.Point,
163163

164164
var result = [[LayerTree.Float]]()
165165

166-
let segments = max(Int(ceil(abs(cc.deltaT) / (LayerTree.Float.tau / 4.0))), 1)
166+
guard let totalSegments = Int(exactly: ceil(abs(cc.deltaT) / (LayerTree.Float.tau / 4.0))) else {
167+
return []
168+
}
169+
let segments = max(totalSegments, 1)
167170
let deltaT = cc.deltaT / LayerTree.Float(segments)
168171

169172
var theta1 = cc.theta

0 commit comments

Comments
 (0)