From c999d29a7b7031fbc827dca740650745d6da0488 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Thu, 24 Jul 2014 13:21:02 +0000 Subject: * fhandler_socket.cc (fhandler_socket::send_internal): Fix value of out_len when tweaking the last buffer so out_len is correct in a subsequent if expression. --- winsup/cygwin/fhandler_socket.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'winsup/cygwin/fhandler_socket.cc') diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc index dbcd2619c..793578f39 100644 --- a/winsup/cygwin/fhandler_socket.cc +++ b/winsup/cygwin/fhandler_socket.cc @@ -1701,9 +1701,13 @@ fhandler_socket::send_internal (struct _WSAMSG *wsamsg, int flags) while (out_len < (unsigned) wmem () && (in_off = 0, ++in_idx < wsamsg->dwBufferCount)); /* Tweak len of the last out_buf buffer so the entire number of bytes - is less than wmem (). */ + is (less than or) equal to wmem (). Fix out_len as well since it's + used in a subsequent test expression. */ if (out_len > (unsigned) wmem ()) - out_buf[out_idx - 1].len -= out_len - (unsigned) wmem (); + { + out_buf[out_idx - 1].len -= out_len - (unsigned) wmem (); + out_len = (unsigned) wmem (); + } /* Add the bytes written from the current last buffer to in_off, so in_off points to the next byte to be written from that buffer, or beyond which lets the outper loop skip to the next buffer. */ -- cgit v1.2.3