This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 1/2] Fix wrong length computed in mi_cmd_data_write_memory_bytes.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]