From 4c587f2586e37c26d69fe96f3719d24051642ccf Mon Sep 17 00:00:00 2001
From: "mathias.chouet" <mathias.chouet@irstea.fr>
Date: Tue, 23 Jul 2019 11:22:44 +0200
Subject: [PATCH] getInferredValuesList() in MINMAX mode : protection against 0
 step

---
 src/param/param-values.ts | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/param/param-values.ts b/src/param/param-values.ts
index e072f726..5452d029 100644
--- a/src/param/param-values.ts
+++ b/src/param/param-values.ts
@@ -119,13 +119,19 @@ export class ParamValues implements IterableValues {
             return this.valueList;
         }
         if (this.valueMode === ParamValueMode.MINMAX) {
-            const values = [ this.min ];
-            let latestVal = this.min + this.step;
-            while (latestVal <= this.max) {
-                values.push(latestVal);
-                latestVal += this.step;
+            // protection against infinite loops
+            if (this.step !== undefined && this.step > 0) {
+                // generate list
+                const values = [ this.min ];
+                let latestVal = this.min + this.step;
+                while (latestVal <= this.max) {
+                    values.push(latestVal);
+                    latestVal += this.step;
+                }
+                return values;
+            } else {
+                return [];
             }
-            return values;
         }
         throw new Error("ParamValues.getInferredValuesList() : incorrect value mode" + ParamValueMode[this.valueMode]);
     }
-- 
GitLab