loleaflet/src/layer/tile/CalcTileLayer.js |   27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

New commits:
commit 0d2dfafc89ed603458d8f3711f1130172ed944f9
Author:     Dennis Francis <dennis.fran...@collabora.com>
AuthorDate: Sat May 16 15:09:51 2020 +0530
Commit:     Dennis Francis <dennis.fran...@collabora.com>
CommitDate: Sun Jul 5 10:03:00 2020 +0200

    Make the newly added interfaces more robust
    
    against wrong argument counts/types.
    
    Change-Id: Ibfed2ba4f3e907ef8a038a3b13b3081cc6248c20
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97950
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Dennis Francis <dennis.fran...@collabora.com>

diff --git a/loleaflet/src/layer/tile/CalcTileLayer.js 
b/loleaflet/src/layer/tile/CalcTileLayer.js
index b7b122ae3..ee8173adf 100644
--- a/loleaflet/src/layer/tile/CalcTileLayer.js
+++ b/loleaflet/src/layer/tile/CalcTileLayer.js
@@ -1193,6 +1193,10 @@ L.SpanList = L.Class.extend({
 
        addCustomDataForEachSpan: function (getCustomDataCallback) {
 
+               if (typeof getCustomDataCallback != 'function') {
+                       return;
+               }
+
                var prevIndex = -1;
                this._spanlist.forEach(function (span) {
                        span.data = getCustomDataCallback(
@@ -1203,6 +1207,11 @@ L.SpanList = L.Class.extend({
        },
 
        getSpanDataByIndex: function (index) {
+
+               if (typeof index != 'number') {
+                       return undefined;
+               }
+
                var spanid = this._searchByIndex(index);
                if (spanid == -1) {
                        return undefined;
@@ -1212,6 +1221,11 @@ L.SpanList = L.Class.extend({
        },
 
        getSpanDataByCustomDataField: function (value, fieldName) {
+
+               if (typeof value != 'number' || typeof fieldName != 'string' || 
!fieldName) {
+                       return undefined;
+               }
+
                var spanid = this._searchByCustomDataField(value, fieldName);
                if (spanid == -1) {
                        return undefined;
@@ -1222,7 +1236,8 @@ L.SpanList = L.Class.extend({
 
        forEachSpanInRange: function (start, end, callback) {
 
-               if (start > end) {
+               if (typeof start != 'number' || typeof end != 'number' ||
+                       typeof callback != 'function' || start > end) {
                        return;
                }
 
@@ -1279,6 +1294,10 @@ L.SpanList = L.Class.extend({
                                var valueStart = prevSpan ?
                                        prevSpan.data[fieldName] + 1 : 0;
                                var valueEnd = curSpan.data[fieldName];
+                               if (valueStart === undefined || valueEnd === 
undefined) {
+                                       // fieldName not present in the 'data' 
property.
+                                       return -1;
+                               }
                                return (testValue < valueStart) ? -1 :
                                        (valueEnd < testValue) ? 1 : 0;
                        });
@@ -1501,7 +1520,7 @@ L.DimensionOutlines = L.Class.extend({
        // 'callback' is called with these parameters : (levelIdx, groupIdx, 
groupStart, groupEnd, groupHidden).
        forEachGroupInRange: function (start, end, callback) {
 
-               if (start === undefined || end === undefined || callback === 
undefined) {
+               if (typeof start != 'number' || typeof end != 'number' || 
typeof callback != 'function') {
                        return;
                }
 
@@ -1575,11 +1594,11 @@ L.DimensionOutlines = L.Class.extend({
 
 function binarySearch(array, key, directionProvider) {
 
-       if (array === undefined || !array.length) {
+       if (!Array.isArray(array) || !array.length) {
                return -1;
        }
 
-       if (directionProvider === undefined) {
+       if (typeof directionProvider != 'function') {
                directionProvider = function (key, testvalue) {
                        return (key === testvalue) ? 0 :
                                (key < testvalue) ? -1 : 1;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to