This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
ubsan: crx: index 5 out of bounds for type 'operand_desc const[5]'
- From: Alan Modra <amodra at gmail dot com>
- To: binutils at sourceware dot org
- Date: Thu, 26 Dec 2019 17:51:07 +1030
- Subject: ubsan: crx: index 5 out of bounds for type 'operand_desc const[5]'
* 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