aboutsummaryrefslogtreecommitdiff
path: root/gdb/windows-nat.c
diff options
context:
space:
mode:
authorPierre Muller <muller@sourceware.org>2012-12-14 07:50:02 +0000
committerPierre Muller <muller@sourceware.org>2012-12-14 07:50:02 +0000
commit49dc7f4b4736a708e8de645ebff64ba5084d33d1 (patch)
tree9d7e2f22406d15e8332e756284657084029938ab /gdb/windows-nat.c
parent62ea864c39e8c34d5d92e9daf94aebe088fa03e9 (diff)
downloadgdb-49dc7f4b4736a708e8de645ebff64ba5084d33d1.zip
gdb-49dc7f4b4736a708e8de645ebff64ba5084d33d1.tar.gz
gdb-49dc7f4b4736a708e8de645ebff64ba5084d33d1.tar.bz2
* windows-nat.c (windows_xfer_shared_libraries): Avoid
memory leak when OFFSET >= LEN_AVAIL.
Diffstat (limited to 'gdb/windows-nat.c')
-rw-r--r--gdb/windows-nat.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 75831d8..cc81a66 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -2411,11 +2411,13 @@ windows_xfer_shared_libraries (struct target_ops *ops,
buf = obstack_finish (&obstack);
len_avail = strlen (buf);
if (offset >= len_avail)
- return 0;
-
- if (len > len_avail - offset)
- len = len_avail - offset;
- memcpy (readbuf, buf + offset, len);
+ len= 0;
+ else
+ {
+ if (len > len_avail - offset)
+ len = len_avail - offset;
+ memcpy (readbuf, buf + offset, len);
+ }
obstack_free (&obstack, NULL);
return len;