8264561: javap get NegativeArraySizeException on bad instruction

Reviewed-by: vromero
This commit is contained in:
Adam Sotona 2021-05-17 15:23:18 +00:00
parent b8856b1c47
commit cf97252f3f
2 changed files with 5 additions and 1 deletions

View File

@ -285,6 +285,8 @@ public class Instruction {
int default_ = getInt(pad);
int low = getInt(pad + 4);
int high = getInt(pad + 8);
if (low > high)
throw new IllegalStateException();
int[] values = new int[high - low + 1];
for (int i = 0; i < values.length; i++)
values[i] = getInt(pad + 12 + 4 * i);
@ -295,6 +297,8 @@ public class Instruction {
int pad = align(pc + 1) - pc;
int default_ = getInt(pad);
int npairs = getInt(pad + 4);
if (npairs < 0)
throw new IllegalStateException();
int[] matches = new int[npairs];
int[] offsets = new int[npairs];
for (int i = 0; i < npairs; i++) {

View File

@ -106,7 +106,7 @@ public class CodeWriter extends BasicWriter {
for (InstructionDetailWriter w: detailWriters)
w.writeDetails(instr);
writeInstr(instr);
} catch (ArrayIndexOutOfBoundsException e) {
} catch (ArrayIndexOutOfBoundsException | IllegalStateException e) {
println(report("error at or after byte " + instr.getPC()));
break;
}