diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2021-01-28 17:17:08 +0000 |
---|---|---|
committer | Andrew Burgess <andrew.burgess@embecosm.com> | 2021-02-08 11:01:07 +0000 |
commit | 93a01471f3df559fffc567247288b3301620c4d7 (patch) | |
tree | ca8460281314070cdfc55776b9aee79056414a3d /sim | |
parent | 0309f9549d8ab359f60790427ca97579dd26eafb (diff) | |
download | gdb-93a01471f3df559fffc567247288b3301620c4d7.zip gdb-93a01471f3df559fffc567247288b3301620c4d7.tar.gz gdb-93a01471f3df559fffc567247288b3301620c4d7.tar.bz2 |
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.
Diffstat (limited to 'sim')
-rw-r--r-- | sim/rx/ChangeLog | 4 | ||||
-rw-r--r-- | sim/rx/gdb-if.c | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/sim/rx/ChangeLog b/sim/rx/ChangeLog index f064039..8d5f1d7 100644 --- a/sim/rx/ChangeLog +++ b/sim/rx/ChangeLog @@ -1,5 +1,9 @@ 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. 2021-02-06 Mike Frysinger <vapier@gentoo.org> diff --git a/sim/rx/gdb-if.c b/sim/rx/gdb-if.c index 6f8bfbd..55eb13d 100644 --- a/sim/rx/gdb-if.c +++ b/sim/rx/gdb-if.c @@ -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; |