Browse Source

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
master
Dave Parker 18 years ago
parent
commit
2e4014c005
  1. 8
      prism/src/parser/ast/ModulesFile.java

8
prism/src/parser/ast/ModulesFile.java

@ -687,6 +687,10 @@ public class ModulesFile extends ASTElement
String s = "Invalid range (" + low + "-" + high + ") for variable \"" + name + "\""; String s = "Invalid range (" + low + "-" + high + ") for variable \"" + name + "\"";
throw new PrismLangException(s, decl); 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 // check start is valid
if (start < low || start > high) { if (start < low || start > high) {
String s = "Invalid initial value (" + start + ") for variable \"" + name + "\""; 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 + "\""; String s = "Invalid range (" + low + "-" + high + ") for variable \"" + name + "\"";
throw new PrismLangException(s, decl); 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 // check start is valid
if (start < low || start > high) { if (start < low || start > high) {
String s = "Invalid initial value (" + start + ") for variable \"" + name + "\""; String s = "Invalid initial value (" + start + ") for variable \"" + name + "\"";

Loading…
Cancel
Save