ubsan: crx: index 5 out of bounds for type 'operand_desc const[5]'

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

ubsan: crx: index 5 out of bounds for type 'operand_desc const[5]'

Alan Modra-3
        * crx-dis.c (get_number_of_operands): Don't access operands[]
        out of bounds.

diff --git a/opcodes/crx-dis.c b/opcodes/crx-dis.c
index 3834748616..e44fca1111 100644
--- a/opcodes/crx-dis.c
+++ b/opcodes/crx-dis.c
@@ -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;

--
Alan Modra
Australia Development Lab, IBM