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

Message ID 20191226072106.GK18153@bubble.grove.modra.org
State New
Headers show
Series
  • ubsan: crx: index 5 out of bounds for type 'operand_desc const[5]'
Related show

Commit Message

Alan Modra Dec. 26, 2019, 7:21 a.m.
* crx-dis.c (get_number_of_operands): Don't access operands[]
	out of bounds.


-- 
Alan Modra
Australia Development Lab, IBM

Patch

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;