Michael Stefaniuc : ws2_32: Avoid using sizeof on structs with variable length array.

Alexandre Julliard julliard at winehq.org
Fri Nov 16 13:12:51 CST 2012


Module: wine
Branch: master
Commit: 0b02d25f6d915a5a4bc1bc6571f97020399c14ff
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=0b02d25f6d915a5a4bc1bc6571f97020399c14ff

Author: Michael Stefaniuc <mstefani at redhat.de>
Date:   Fri Nov 16 11:11:57 2012 +0100

ws2_32: Avoid using sizeof on structs with variable length array.

---

 dlls/ws2_32/socket.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index 5c69d21..ceda75b 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -1912,7 +1912,7 @@ static int WS2_register_async_shutdown( SOCKET s, int type )
 
     TRACE("s %ld type %d\n", s, type);
 
-    wsa = HeapAlloc( GetProcessHeap(), 0, sizeof(*wsa) );
+    wsa = HeapAlloc( GetProcessHeap(), 0, FIELD_OFFSET( struct ws2_async, iovec[1] ));
     if ( !wsa )
         return WSAEFAULT;
 
@@ -2450,7 +2450,7 @@ static BOOL WINAPI WS2_ConnectEx(SOCKET s, const struct WS_sockaddr* name, int n
                       FD_WINE_CONNECTED|FD_WINE_LISTENING);
 
         /* Indirectly call WSASend */
-        if (!(wsa = HeapAlloc( GetProcessHeap(), 0, sizeof(*wsa) )))
+        if (!(wsa = HeapAlloc( GetProcessHeap(), 0, FIELD_OFFSET( struct ws2_async, iovec[1] ))))
         {
             SetLastError(WSAEFAULT);
         }




More information about the wine-cvs mailing list