summaryrefslogtreecommitdiff
path: root/gdb/windows-nat.c
diff options
context:
space:
mode:
authorPierre Muller <muller@ics.u-strasbg.fr>2012-12-14 07:49:59 +0000
committerPierre Muller <muller@ics.u-strasbg.fr>2012-12-14 07:49:59 +0000
commite0f33342f023cfe1e39f6ed72cbfea0f08ae8749 (patch)
treef41fb876c3e74951f3bee4b97a2af30f9c949f7b /gdb/windows-nat.c
parent5d92b8fa316107f0fad7668e094d86342da83978 (diff)
downloadgdb-e0f33342f023cfe1e39f6ed72cbfea0f08ae8749.tar.gz
* 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 75831d821c3..cc81a66ff7f 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;