From 004626c15abec926ce47bfc4c19f99cf2aecd8b2 Mon Sep 17 00:00:00 2001 From: thk123 Date: Thu, 8 Feb 2018 17:25:50 +0000 Subject: [PATCH] Adding invariant to check instruction is normal wide Only specific instructions can follow a wide byte. --- src/java_bytecode/java_bytecode_parser.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/java_bytecode/java_bytecode_parser.cpp b/src/java_bytecode/java_bytecode_parser.cpp index 58bfc4f09b5..85c63e263b5 100644 --- a/src/java_bytecode/java_bytecode_parser.cpp +++ b/src/java_bytecode/java_bytecode_parser.cpp @@ -711,6 +711,13 @@ void java_bytecode_parsert::rbytecode( wide_instruction=true; address++; bytecode=read_u1(); + // The only valid instructions following a wide byte are + // [ifald]load, [ifald]store, ret and iinc + // All of these have either format of v, or V + INVARIANT( + bytecodes[bytecode].format == 'v' || bytecodes[bytecode].format == 'V', + "Unexpected wide instruction: " + + id2string(bytecodes[bytecode].mnemonic)); } instructions.push_back(instructiont());