[lldb] Fix out-of-bounds read after c3ea7c66fec021867e005ad1b02f3c7e80feaa85
authorJames Y Knight <jyknight@google.com>
Tue, 4 Jun 2019 15:27:19 +0000 (15:27 +0000)
committerJames Y Knight <jyknight@google.com>
Tue, 4 Jun 2019 15:27:19 +0000 (15:27 +0000)
"Add support for mid-function epilogues on x86 that end in a non-local jump."

Detected by asan.

llvm-svn: 362510

lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp

index e4d5ff0..af54115 100644 (file)
@@ -736,7 +736,6 @@ bool x86AssemblyInspectionEngine::pc_rel_branch_or_jump_p (
   int opcode_size = 0;
 
   uint8_t b1 = m_cur_insn[0];
-  uint8_t b2 = m_cur_insn[1];
 
   switch (b1) {
     case 0x77: // JA/JNBE rel8
@@ -764,6 +763,7 @@ bool x86AssemblyInspectionEngine::pc_rel_branch_or_jump_p (
       break;
   }
   if (b1 == 0x0f && opcode_size == 0) {
+    uint8_t b2 = m_cur_insn[1];
     switch (b2) {
       case 0x87: // JA/JNBE rel16/rel32
       case 0x86: // JBE/JNA rel16/rel32