sprintf arg overlaps destination

* csky-dis.c (csky_output_operand): Don't sprintf str to itself.
This commit is contained in:
Alan Modra
2020-09-10 14:12:52 +09:30
parent a3a08c5a2f
commit 23bef3fea3
2 changed files with 8 additions and 4 deletions

View File

@ -1,3 +1,7 @@
2020-09-10 Alan Modra <amodra@gmail.com>
* csky-dis.c (csky_output_operand): Don't sprintf str to itself.
2020-09-07 Cooper Qu <cooper.qu@linux.alibaba.com> 2020-09-07 Cooper Qu <cooper.qu@linux.alibaba.com>
* csky-opc.h (csky_v2_opcodes): Change mvtc and mulsw's * csky-opc.h (csky_v2_opcodes): Change mvtc and mulsw's

View File

@ -647,8 +647,8 @@ csky_output_operand (char *str, struct operand const *oprnd,
float f = 0; float f = 0;
memcpy (&f, &value, sizeof (float)); memcpy (&f, &value, sizeof (float));
sprintf (str, "%s%f\t// imm9:%4d, imm4:%2d", str, f, imm8, imm4); sprintf (buf, "%f\t// imm9:%4d, imm4:%2d", f, imm8, imm4);
strcat (str, buf);
break; break;
} }
@ -675,8 +675,8 @@ csky_output_operand (char *str, struct operand const *oprnd,
} }
double d = 0; double d = 0;
memcpy (&d, &dvalue, sizeof (double)); memcpy (&d, &dvalue, sizeof (double));
sprintf (str, "%s%lf\t// imm9:%4ld, imm4:%2ld", str, d, imm8, imm4); sprintf (buf, "%lf\t// imm9:%4ld, imm4:%2ld", d, imm8, imm4);
strcat (str, buf);
break; break;
} }
case OPRND_TYPE_LABEL_WITH_BRACKET: case OPRND_TYPE_LABEL_WITH_BRACKET: