changeset 560:b202fbfc7dea

[xemacs-hg @ 2001-05-23 11:29:58 by ben] event-msw.c: prior kludgy code was clobbering the buffer, thinking it was "unused" space to store an unneeded return value; instead, use the variable we've already got staring us in the face.
author ben
date Wed, 23 May 2001 11:30:01 +0000
parents 5101772788b2
children 1dac8639fe3f
files src/ChangeLog src/event-msw.c
diffstat 2 files changed, 16 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Wed May 23 10:02:19 2001 +0000
+++ b/src/ChangeLog	Wed May 23 11:30:01 2001 +0000
@@ -1,3 +1,11 @@
+2001-05-23  Ben Wing  <ben@xemacs.org>
+
+	* event-msw.c (winsock_writer):
+	* event-msw.c (winsock_closer):
+	prior kludgy code was clobbering the buffer, thinking it was
+	"unused" space to store an unneeded return value; instead, use
+	the variable we've already got staring us in the face.
+
 2001-05-23  Ben Wing  <ben@xemacs.org>
 
 	for 21.5:
--- a/src/event-msw.c	Wed May 23 10:02:19 2001 +0000
+++ b/src/event-msw.c	Wed May 23 11:30:01 2001 +0000
@@ -782,10 +782,10 @@
   str->buffer = xrealloc (str->buffer, size);
   memcpy (str->buffer, data, size);
 
-  /* Docs indicate that 4th parameter to WriteFile can be NULL since this is
-   * an overlapped operation. This fails on Win95 with winsock 1.x so we
-   * supply a spare address which is ignored by Win95 anyway. Sheesh. */
-  if (WriteFile ((HANDLE)str->s, str->buffer, size, (LPDWORD)&str->buffer,
+  /* According to MSDN WriteFile docs, the fourth parameter cannot be NULL
+     on Win95 even when doing an overlapped operation, as we are, where
+     the return value through that parameter is not meaningful. */
+  if (WriteFile ((HANDLE)str->s, str->buffer, size, &str->bufsize,
 		 &str->ov)
       || GetLastError() == ERROR_IO_PENDING)
     str->pending_p = 1;
@@ -810,7 +810,10 @@
     WaitForSingleObject (str->ov.hEvent, INFINITE);
 
   if (str->buffer)
-    xfree (str->buffer);
+    {
+      xfree (str->buffer);
+      str->buffer = 0;
+    }
 
   CloseHandle (str->ov.hEvent);
   return 0;