Unknown conditions cause index out of bounds error leading to a

null pointer deref.  this patch returns null instead of bad index
out of bounds read and a null pointer check.

This would trigger on an action in a table that has only an assign
This commit is contained in:
mumbel 2019-07-17 17:53:42 -05:00
parent ac474530f4
commit af7bdb78d9
2 changed files with 6 additions and 1 deletions

View file

@ -50,6 +50,8 @@ public class OperandValue extends PatternValue {
@Override
public TokenPattern genMinPattern(VectorSTL<TokenPattern> ops) {
if (index >= ops.size())
return null;
return ops.get(index);
}

View file

@ -542,7 +542,10 @@ public class Constructor {
}
}
else if (defexp != null) {
oppattern.push_back(defexp.genMinPattern(oppattern));
TokenPattern tmppat = defexp.genMinPattern(oppattern);
if (null == tmppat)
throw new SleighError("operand " + sym.getName() + " has an issue", location);
oppattern.push_back(tmppat);
}
else {
throw new SleighError("operand " + sym.getName() + " is undefined", location);