From 6217bf3e40f132256f135ae6f5e6fa4263db6982 Mon Sep 17 00:00:00 2001 From: Michael Snyder Date: Wed, 8 Aug 2007 22:02:43 +0000 Subject: [PATCH] 2007-08-08 Michael Snyder * target.c (target_read_string): Guard against null. --- gdb/ChangeLog | 2 ++ gdb/target.c | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9e9724f1496..6b3636c5d83 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,7 @@ 2007-08-08 Michael Snyder + * 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 92a4d6ac2c9..38d6f68c7ba 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; } -- 2.30.2