ws2_32: make gethostbyname fail if WSAStartup was not called before [try 2]
Alexandre Goujon
ale.goujon at gmail.com
Tue Feb 22 13:40:00 CST 2011
---
dlls/ws2_32/socket.c | 4 ++++
dlls/ws2_32/tests/sock.c | 4 ++--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index f3a521c..f74fd36 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -4606,6 +4606,10 @@ struct WS_hostent* WINAPI WS_gethostbyname(const char* name)
int locerr = ENOBUFS;
#endif
char hostname[100];
+ if(!num_startup) {
+ SetLastError(WSANOTINITIALISED);
+ return NULL;
+ }
if( gethostname( hostname, 100) == -1) {
SetLastError( WSAENOBUFS); /* appropriate ? */
return retval;
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index de647f1..1fc6cf0 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -843,8 +843,8 @@ static void test_WithoutWSAStartup(void)
WSASetLastError(0xdeadbeef);
ptr = gethostbyname("localhost");
- todo_wine ok(ptr == NULL, "gethostbyname() succeeded unexpectedly: %d\n", WSAGetLastError());
- todo_wine ok(WSAGetLastError() == WSANOTINITIALISED, "gethostbyname() failed with unexpected error: %d\n",
+ ok(ptr == NULL, "gethostbyname() succeeded unexpectedly: %d\n", WSAGetLastError());
+ ok(WSAGetLastError() == WSANOTINITIALISED, "gethostbyname() failed with unexpected error: %d\n",
WSAGetLastError());
}
--
1.7.0.4
More information about the wine-patches
mailing list