This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 1/2] Fix wrong length computed in mi_cmd_data_write_memory_bytes.
- From: Yao Qi <yao at codesourcery dot com>
- To: <gdb-patches at sourceware dot org>
- Date: Wed, 26 Sep 2012 18:24:41 +0800
- Subject: [PATCH 1/2] Fix wrong length computed in mi_cmd_data_write_memory_bytes.
- References: <1348655082-4334-1-git-send-email-yao@codesourcery.com>
Hi,
I happen to see that MI command '-data-write-memory-bytes' doesn't write
contents correctly to memory, for example,
-data-write-memory-bytes &x "1"
^done
p/x x
&"p/x x\n"
~"$1 = 0x2a\n"
^done
or,
-data-write-memory-bytes &x "123"
^done
p/x x
&"p/x x\n"
~"$1 = 0x12\n"
^done
Looks the local variable 'LEN' is computed by mistake, and this patch is
to fix it.
gdb:
2012-09-26 Yao Qi <yao@codesourcery.com>
* mi/mi-main.c (mi_cmd_data_write_memory_bytes): Fix wrong value
of 'len'.
---
gdb/mi/mi-main.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index f1d21bc..c96615b 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -1672,7 +1672,7 @@ mi_cmd_data_write_memory_bytes (char *command, char **argv, int argc)
addr = parse_and_eval_address (argv[0]);
cdata = argv[1];
- len = strlen (cdata)/2;
+ len = (strlen (cdata) + 1)/2;
data = xmalloc (len);
back_to = make_cleanup (xfree, data);
--
1.7.7.6