Fix a potential illegal array access in the D30V disassembler.
authorNick Clifton <nickc@redhat.com>
Tue, 29 Oct 2019 10:25:09 +0000 (10:25 +0000)
committerNick Clifton <nickc@redhat.com>
Tue, 29 Oct 2019 10:25:09 +0000 (10:25 +0000)
* d30v-dis.c (print_insn): Check that operand index is valid
before attempting to access the operands array.

opcodes/ChangeLog
opcodes/d30v-dis.c

index d596729a11637f696e9b5fa8c869f6eb57ad8b54..ae2e00ce9b65ad022f5fe7a4981e40a3c7cd2e1f 100644 (file)
@@ -1,3 +1,8 @@
+2019-10-29  Nick Clifton  <nickc@redhat.com>
+
+       * d30v-dis.c (print_insn): Check that operand index is valid
+       before attempting to access the operands array.
+
 2019-10-29  Nick Clifton  <nickc@redhat.com>
 
        * ia64-opc.c (locate_opcode_ent): Prevent a negative shift when
index 2861ca5ad085fa3b44f8cadfb573ddeae88d8118..8dd43fb984e0361f86664497419bec6893847d3f 100644 (file)
@@ -23,6 +23,7 @@
 #include "opcode/d30v.h"
 #include "disassemble.h"
 #include "opintl.h"
+#include "libiberty.h"
 
 #define PC_MASK 0xFFFFFFFF
 
@@ -313,7 +314,9 @@ print_insn (struct disassemble_info *info,
          (*info->fprintf_func) (info->stream, "0x%x", val);
        }
       /* If there is another operand, then write a comma and space.  */
-      if (insn->form->operands[opind] && !(found_control && opind == 2))
+      if (opind < (int) ARRAY_SIZE (insn->form->operands)
+         && insn->form->operands[opind]
+         && !(found_control && opind == 2))
        need_comma = 1;
     }
   if (need_paren)