From 3b2fcdd42600b3893a543ad2232b2d7217bb9f54 Mon Sep 17 00:00:00 2001 From: Bruno Jesus <00cpxxx@gmail.com> Date: Tue, 10 Apr 2012 23:25:56 -0300 Subject: [PATCH] ws2_32/tests: Avoid crashing if getservbyname fails. --- dlls/ws2_32/tests/sock.c | 1 + 1 file changed, 1 insertion(+) diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index 9fd6abbce1d..f3b33bee66d 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -1600,6 +1600,7 @@ static DWORD WINAPI do_getservbyname( void *param ) for ( j = 0; j < 2; j++ ) { pserv[j] = getservbyname ( serv[j].name, serv[j].proto ); ok ( pserv[j] != NULL, "getservbyname could not retrieve information for %s: %d\n", serv[j].name, WSAGetLastError() ); + if ( !pserv[j] ) continue; ok ( pserv[j]->s_port == htons(serv[j].port), "getservbyname returned the wrong port for %s: %d\n", serv[j].name, ntohs(pserv[j]->s_port) ); ok ( !strcmp ( pserv[j]->s_proto, serv[j].proto ), "getservbyname returned the wrong protocol for %s: %s\n", serv[j].name, pserv[j]->s_proto ); ok ( !strcmp ( pserv[j]->s_name, serv[j].name ), "getservbyname returned the wrong name for %s: %s\n", serv[j].name, pserv[j]->s_name );