From 49dc7f4b4736a708e8de645ebff64ba5084d33d1 Mon Sep 17 00:00:00 2001 From: Pierre Muller Date: Fri, 14 Dec 2012 07:50:02 +0000 Subject: * windows-nat.c (windows_xfer_shared_libraries): Avoid memory leak when OFFSET >= LEN_AVAIL. --- gdb/windows-nat.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'gdb/windows-nat.c') 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; -- cgit v1.1