aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/fhandler.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2005-11-08 23:25:55 +0000
committerChristopher Faylor <me@cgf.cx>2005-11-08 23:25:55 +0000
commit8eb445cfd3df7dcb6b83304bc1f918985965e1af (patch)
tree388cefddad08297a7113522de4334d68b5f6aa45 /winsup/cygwin/fhandler.cc
parentb397593c94941f7ef41a265e065f57dffaa7e9bd (diff)
downloadnewlib-8eb445cfd3df7dcb6b83304bc1f918985965e1af.zip
newlib-8eb445cfd3df7dcb6b83304bc1f918985965e1af.tar.gz
newlib-8eb445cfd3df7dcb6b83304bc1f918985965e1af.tar.bz2
* fhandler_base.cc (fhandler_base::readv): Free buf, not a pointer into the
middle of buf.
Diffstat (limited to 'winsup/cygwin/fhandler.cc')
-rw-r--r--winsup/cygwin/fhandler.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index a8a2786..6931cb6 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -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;
}