Skip to content

Commit

Permalink
Prevent nextPos for connectEdges from accessing past end of array (w/…
Browse files Browse the repository at this point in the history
…additional checks) (#147)

* rebuilt with out-of-index PR

* added dist

* added another out of bounds check

* added another bounds check

* version change

* added another check

* updated version

* updated version

* updated with error catching

* added back dist for merging

* added space in .gitignore

* replaced version number

* removed dist files

* removed yarn.lock

* cleaning up package.json
  • Loading branch information
David Figatner committed Mar 30, 2022
1 parent a1bb07e commit 2e49fe9
Show file tree
Hide file tree
Showing 4 changed files with 7,624 additions and 1,884 deletions.
20 changes: 12 additions & 8 deletions demo/js/bundle.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(function (L$1) {
'use strict';

L$1 = L$1 && L$1.hasOwnProperty('default') ? L$1['default'] : L$1;
L$1 = L$1 && Object.prototype.hasOwnProperty.call(L$1, 'default') ? L$1['default'] : L$1;

L$1.Coordinates = L$1.Control.extend({
options: {
Expand Down Expand Up @@ -1663,7 +1663,7 @@
if (next) {
if (possibleIntersection(event, next.key, eventQueue) === 2) {
computeFields(event, prevEvent, operation);
computeFields(event, next.key, operation);
computeFields(next.key, event, operation);
}
}

Expand Down Expand Up @@ -1768,8 +1768,8 @@
*/
function nextPos(pos, resultEvents, processed, origPos) {
var newPos = pos + 1,
p = resultEvents[pos].point,
p1;
p = resultEvents[pos].point,
p1;
var length = resultEvents.length;

if (newPos < length)
Expand All @@ -1778,10 +1778,12 @@
while (newPos < length && p1[0] === p[0] && p1[1] === p[1]) {
if (!processed[newPos]) {
return newPos;
} else {
} else {
newPos++;
}
p1 = resultEvents[newPos].point;
if (newPos < length) {
p1 = resultEvents[newPos].point;
}
}

newPos = pos - 1;
Expand Down Expand Up @@ -1859,7 +1861,9 @@
// Helper function that combines marking an event as processed with assigning its output contour ID
var markAsProcessed = function (pos) {
processed[pos] = true;
resultEvents[pos].outputContourId = contourId;
if (pos < resultEvents.length && resultEvents[pos]) {
resultEvents[pos].outputContourId = contourId;
}
};

var pos = i;
Expand All @@ -1879,7 +1883,7 @@

pos = nextPos(pos, resultEvents, processed, origPos);

if (pos == origPos) {
if (pos == origPos || pos >= resultEvents.length || !resultEvents[pos]) {
break;
}
}
Expand Down
Loading

0 comments on commit 2e49fe9

Please sign in to comment.