From 2e4014c0059500578178fcea66cb1b16ed89cc7f Mon Sep 17 00:00:00 2001 From: Dave Parker Date: Wed, 18 Jun 2008 14:16:09 +0000 Subject: [PATCH] Added error checking for var ranges that are too big. git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@798 bbc10eb1-c90d-0410-af57-cb519fbb1720 --- prism/src/parser/ast/ModulesFile.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/prism/src/parser/ast/ModulesFile.java b/prism/src/parser/ast/ModulesFile.java index fd2a9168..3cd268ff 100644 --- a/prism/src/parser/ast/ModulesFile.java +++ b/prism/src/parser/ast/ModulesFile.java @@ -687,6 +687,10 @@ public class ModulesFile extends ASTElement String s = "Invalid range (" + low + "-" + high + ") for variable \"" + name + "\""; throw new PrismLangException(s, decl); } + if ((long)high - (long)low >= Integer.MAX_VALUE) { + String s = "Range for variable \"" + name + "\" (" + low + "-" + high + ") is too big"; + throw new PrismLangException(s, decl); + } // check start is valid if (start < low || start > high) { String s = "Invalid initial value (" + start + ") for variable \"" + name + "\""; @@ -720,6 +724,10 @@ public class ModulesFile extends ASTElement String s = "Invalid range (" + low + "-" + high + ") for variable \"" + name + "\""; throw new PrismLangException(s, decl); } + if ((long)high - (long)low >= Integer.MAX_VALUE) { + String s = "Range for variable \"" + name + "\" (" + low + "-" + high + ") is too big"; + throw new PrismLangException(s, decl); + } // check start is valid if (start < low || start > high) { String s = "Invalid initial value (" + start + ") for variable \"" + name + "\"";