* fhandler_base.cc (fhandler_base::readv): Free buf, not a pointer into the

middle of buf.
This commit is contained in:
Christopher Faylor 2005-11-08 23:25:55 +00:00
parent b397593c94
commit 8eb445cfd3
2 changed files with 9 additions and 3 deletions

View File

@ -1,3 +1,8 @@
2005-11-08 Christopher Faylor <cgf@timesys.com>
* fhandler_base.cc (fhandler_base::readv): Free buf, not a pointer into
the middle of buf.
2005-11-08 Christopher Faylor <cgf@timesys.com>
* memmem.cc: New file.

View File

@ -969,7 +969,7 @@ fhandler_base::readv (const struct iovec *const iov, const int iovcnt,
if (!len)
return 0;
char *buf = (char *) malloc (tot);
char *buf = (char *) malloc (len);
if (!buf)
{
@ -982,11 +982,12 @@ fhandler_base::readv (const struct iovec *const iov, const int iovcnt,
const struct iovec *iovptr = iov;
char *p = buf;
while (nbytes > 0)
{
const int frag = min (nbytes, (ssize_t) iovptr->iov_len);
memcpy (iovptr->iov_base, buf, frag);
buf += frag;
memcpy (iovptr->iov_base, p, frag);
p += frag;
iovptr += 1;
nbytes -= frag;
}