ws2_32: Avoid writing to NULL pointer (coverity)

Bruno Jesus 00cpxxx at gmail.com
Wed Dec 4 21:01:50 CST 2013


Due to the format set in sprintf this is impossible to happen, but coverity
is not content aware and complains that the strstr may return NULL. This
patch should make it happy.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20131205/cc52e73d/attachment.html>
-------------- next part --------------
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index 304b0eb..9168b45 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -6939,7 +6939,7 @@ INT WINAPI WSAAddressToStringA( LPSOCKADDR sockaddr, DWORD len,
                ntohs( ((SOCKADDR_IN *)sockaddr)->sin_port ) );
 
         p = strchr( buffer, ':' );
-        if (!((SOCKADDR_IN *)sockaddr)->sin_port) *p = 0;
+        if (p && !((SOCKADDR_IN *)sockaddr)->sin_port) *p = 0;
         break;
 
     case WS_AF_INET6:


More information about the wine-patches mailing list