ubsan: crx: index 5 out of bounds for type 'operand_desc const[5]'
authorAlan Modra <amodra@gmail.com>
Thu, 26 Dec 2019 05:34:20 +0000 (16:04 +1030)
committerAlan Modra <amodra@gmail.com>
Thu, 26 Dec 2019 07:19:03 +0000 (17:49 +1030)
* crx-dis.c (get_number_of_operands): Don't access operands[]
out of bounds.

opcodes/ChangeLog
opcodes/crx-dis.c

index 07f30e27d6be9e2a73d68290380952cd7c84cf97..25c29b235cbc840cafcf125e81e89b59deb5813f 100644 (file)
@@ -1,3 +1,8 @@
+2019-12-26  Alan Modra  <amodra@gmail.com>
+
+       * crx-dis.c (get_number_of_operands): Don't access operands[]
+       out of bounds.
+
 2019-12-26  Alan Modra  <amodra@gmail.com>
 
        * v850-dis.c (disassemble): Avoid signed overflow.  Don't use
index 38347486169f107d74ffab7db86ed3dc176b9ce6..e44fca111145ca0b0781b933109a1685bef50f80 100644 (file)
@@ -105,7 +105,7 @@ get_number_of_operands (void)
 {
   int i;
 
-  for (i = 0; instruction->operands[i].op_type && i < MAX_OPERANDS; i++)
+  for (i = 0; i < MAX_OPERANDS && instruction->operands[i].op_type; i++)
     ;
 
   return i;