ussan: d30v: index out of bounds
authorAlan Modra <amodra@gmail.com>
Tue, 10 Dec 2019 13:20:02 +0000 (23:50 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 11 Dec 2019 01:09:07 +0000 (11:39 +1030)
* d30v-dis.c (print_insn): Make opind unsigned.  Don't access
past end of operands array.

opcodes/ChangeLog
opcodes/d30v-dis.c

index 5cd7361512bc96ea719521cf764196beb41b0543..946c6201106999b062fb67300505a7f97299692c 100644 (file)
@@ -1,3 +1,8 @@
+2019-12-11  Alan Modra  <amodra@gmail.com>
+
+       * d30v-dis.c (print_insn): Make opind unsigned.  Don't access
+       past end of operands array.
+
 2019-12-11  Alan Modra  <amodra@gmail.com>
 
        * csky-dis.c (csky_chars_to_number): Rewrite.  Avoid signed
index 8dd43fb984e0361f86664497419bec6893847d3f..d2e0caa39d73372ac1ab57fa20beaed9fb5049c9 100644 (file)
@@ -125,7 +125,8 @@ print_insn (struct disassemble_info *info,
 {
   int val, opnum, need_comma = 0;
   struct d30v_operand *oper;
-  int i, match, opind = 0, need_paren = 0, found_control = 0;
+  int i, match, need_paren = 0, found_control = 0;
+  unsigned int opind = 0;
 
   (*info->fprintf_func) (info->stream, "%s", insn->op->name);
 
@@ -154,7 +155,8 @@ print_insn (struct disassemble_info *info,
 
   (*info->fprintf_func) (info->stream, "\t");
 
-  while ((opnum = insn->form->operands[opind++]) != 0)
+  while (opind < ARRAY_SIZE (insn->form->operands)
+        && (opnum = insn->form->operands[opind++]) != 0)
     {
       int bits;
 
@@ -314,7 +316,7 @@ 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 (opind < (int) ARRAY_SIZE (insn->form->operands)
+      if (opind < ARRAY_SIZE (insn->form->operands)
          && insn->form->operands[opind]
          && !(found_control && opind == 2))
        need_comma = 1;
This page took 0.025292 seconds and 4 git commands to generate.