Skip to content

Commit

Permalink
Catch infinite loop when passing sweep line over endpoints (mfogel#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
OliverColeman committed Jun 17, 2020
1 parent a2d4163 commit 44a36ac
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/operation.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,23 @@ export class Operation {
'Please file a bug report.'
)
}

if (queue.size > 1000000) {
// prevents an infinite loop, an otherwise common manifestation of bugs
throw new Error(
'Infinite loop when passing sweep line over endpoints ' +
'(queue size too big). Please file a bug report.'
)
}

if (sweepLine.segments.length > 1000000) {
// prevents an infinite loop, an otherwise common manifestation of bugs
throw new Error(
'Infinite loop when passing sweep line over endpoints ' +
'(too many sweep line segments). Please file a bug report.'
)
}

const newEvents = sweepLine.process(evt)
for (let i = 0, iMax = newEvents.length; i < iMax; i++) {
const evt = newEvents[i]
Expand Down

0 comments on commit 44a36ac

Please sign in to comment.