Bounds-check array access in Polygon#initialize
This commit is contained in:
parent
e032046119
commit
c9e2453eed
@ -19,6 +19,11 @@ describe('Polygon', function() {
|
||||
expect(sourceLatLngs).to.eql(originalLatLngs);
|
||||
expect(polygon._latlngs).to.not.eql(sourceLatLngs);
|
||||
});
|
||||
|
||||
it("can be called with an empty array", function () {
|
||||
var polygon = new L.Polygon([]);
|
||||
expect(polygon.getLatLngs()).to.eql([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#setLatLngs", function () {
|
||||
|
@ -27,7 +27,7 @@ L.Polygon = L.Polyline.extend({
|
||||
// filter out last point if its equal to the first one
|
||||
latlngs = this._latlngs;
|
||||
|
||||
if (latlngs[0].equals(latlngs[latlngs.length - 1])) {
|
||||
if (latlngs.length >= 2 && latlngs[0].equals(latlngs[latlngs.length - 1])) {
|
||||
latlngs.pop();
|
||||
}
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user