diff options
author | Christopher Faylor <me@cgf.cx> | 2005-11-08 23:25:55 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2005-11-08 23:25:55 +0000 |
commit | 8eb445cfd3df7dcb6b83304bc1f918985965e1af (patch) | |
tree | 388cefddad08297a7113522de4334d68b5f6aa45 /winsup/cygwin/fhandler.cc | |
parent | b397593c94941f7ef41a265e065f57dffaa7e9bd (diff) | |
download | newlib-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.cc | 7 |
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; } |