Permalink
Browse files

Added a missing close() function after a unsuccessful connect() call,…

… and removed WSACleanup() when WSAStartup failed.
  • Loading branch information...
haakonnessjoen committed May 23, 2014
1 parent 66887fa commit 9a8b9e15cc3bb4c55b78900a2f4a84ce7e13313f
Showing with 3 additions and 1 deletion.
  1. +3 −1 librouteros.c
View
@@ -349,7 +349,6 @@ struct ros_connection *ros_connect(char *address, int port) {
#ifdef _WIN32
if ((retval = WSAStartup(0x202, &wsaData)) != 0) {
fprintf(stderr,"Server: WSAStartup() failed with error %d\n", retval);
- WSACleanup();
free(conn);
return NULL;
}
@@ -383,7 +382,10 @@ struct ros_connection *ros_connect(char *address, int port) {
#endif
) {
#ifdef _WIN32
+ closesocket(conn->socket);
WSACleanup();
+#else
+ close(conn->socket);
#endif
free(conn);
return NULL;

0 comments on commit 9a8b9e1

Please sign in to comment.