diff options
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 2 | ||||
-rw-r--r-- | gdb/target.c | 5 |
2 files changed, 5 insertions, 2 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9e9724f..6b3636c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,7 @@ 2007-08-08 Michael Snyder <msnyder@access-company.com> + * target.c (target_read_string): Guard against null. + * varobj.c (value_of_root): Move alloc after return to avoid leak. * tui/tui-layout.c (tui_set_layout): Dead code, dead variable. diff --git a/gdb/target.c b/gdb/target.c index 92a4d6a..38d6f68 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -919,6 +919,8 @@ target_read_string (CORE_ADDR memaddr, char **string, int len, int *errnop) char *bufptr; unsigned int nbytes_read = 0; + gdb_assert (string); + /* Small for testing. */ buffer_allocated = 4; buffer = xmalloc (buffer_allocated); @@ -968,10 +970,9 @@ target_read_string (CORE_ADDR memaddr, char **string, int len, int *errnop) nbytes_read += tlen; } done: + *string = buffer; if (errnop != NULL) *errnop = errcode; - if (string != NULL) - *string = buffer; return nbytes_read; } |