sim/rx: fix an issue where we try to modify a const string

While experimenting with switching on warnings for the rx simulator I
discovered this bug.  In sim_do_command we get passed a 'const char *'
argument.  We create a copy of this string to work with locally, but
then while processing this we accidentally switch back to reference
the original string.

sim/rx/ChangeLog:

	* gdb-if.c (sim_do_command): Work with a copy of the command.
This commit is contained in:
Andrew Burgess
2021-01-28 17:17:08 +00:00
parent 0309f9549d
commit 93a01471f3
2 changed files with 6 additions and 2 deletions

View File

@@ -1,3 +1,7 @@
2021-02-08 Andrew Burgess <andrew.burgess@embecosm.com>
* gdb-if.c (sim_do_command): Work with a copy of the command.
2021-02-08 Andrew Burgess <andrew.burgess@embecosm.com>
* gdb-if.c (sim_memory_map): New function.

View File

@@ -804,13 +804,13 @@ sim_do_command (SIM_DESC sd, const char *cmd)
p++;
/* Find the extent of the command word. */
for (p = cmd; *p; p++)
for (; *p != '\0'; p++)
if (isspace (*p))
break;
/* Null-terminate the command word, and record the start of any
further arguments. */
if (*p)
if (*p != '\0')
{
*p = '\0';
args = p + 1;