* windows-nat.c (windows_xfer_shared_libraries): Avoid

memory leak when OFFSET >= LEN_AVAIL.
This commit is contained in:
Pierre Muller 2012-12-14 07:50:02 +00:00
parent 62ea864c39
commit 49dc7f4b47
2 changed files with 12 additions and 5 deletions

View File

@ -1,3 +1,8 @@
2012-12-14 Pierre Muller <muller@sourceware.org>
* windows-nat.c (windows_xfer_shared_libraries): Avoid
memory leak when OFFSET >= LEN_AVAIL.
2012-12-13 Tom Tromey <tromey@redhat.com>
* solib-svr4.c (enable_break): Use SECT_OFF_TEXT.

View File

@ -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;