OSDN Git Service

* fhandler_base.cc (fhandler_base::readv): Free buf, not a pointer into the
authorcgf <cgf>
Tue, 8 Nov 2005 23:25:55 +0000 (23:25 +0000)
committercgf <cgf>
Tue, 8 Nov 2005 23:25:55 +0000 (23:25 +0000)
middle of buf.

winsup/cygwin/ChangeLog
winsup/cygwin/fhandler.cc

index 30ca401..d51714b 100644 (file)
@@ -1,5 +1,10 @@
 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.
        * include/cygwin/version.h: Bump API version number to 142.
        * cygwin.din: Export memmem.
index a8a2786..6931cb6 100644 (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;
     }