aboutsummaryrefslogtreecommitdiff
path: root/gas/config/tc-cr16.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-08-25 15:34:10 +0930
committerAlan Modra <amodra@gmail.com>2020-08-25 23:07:10 +0930
commitd3e0baddb206bc7c5ad5beb0c4ac3db8a5feb889 (patch)
treecdad75697a4e556751dad03949f20f493968fbfa /gas/config/tc-cr16.c
parent0c1438eb15a31098ba42427e0f48e4e5cc6bfe0b (diff)
downloadbinutils-d3e0baddb206bc7c5ad5beb0c4ac3db8a5feb889.zip
binutils-d3e0baddb206bc7c5ad5beb0c4ac3db8a5feb889.tar.gz
binutils-d3e0baddb206bc7c5ad5beb0c4ac3db8a5feb889.tar.bz2
PR26441, ASAN: get_b_cc tc-cr16.c:1521
PR 26441 * config/tc-cr16.c (get_b_cc): Return NULL early if op isn't two or three chars, and don't bother copying.
Diffstat (limited to 'gas/config/tc-cr16.c')
-rw-r--r--gas/config/tc-cr16.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/gas/config/tc-cr16.c b/gas/config/tc-cr16.c
index e85e5fa..32eda77 100644
--- a/gas/config/tc-cr16.c
+++ b/gas/config/tc-cr16.c
@@ -1513,15 +1513,12 @@ static char *
get_b_cc (char * op)
{
unsigned int i;
- char op1[5];
- for (i = 1; i < strlen (op); i++)
- op1[i-1] = op[i];
-
- op1[i-1] = '\0';
+ if (op[1] == 0 || (op[2] != 0 && op[3] != 0))
+ return NULL;
for (i = 0; i < cr16_num_cc ; i++)
- if (streq (op1, cr16_b_cond_tab[i]))
+ if (streq (op + 1, cr16_b_cond_tab[i]))
return (char *) cr16_b_cond_tab[i];
return NULL;