Skip to content

Commit

Permalink
Added a missing close() function after a unsuccessful connect() call,…
Browse files Browse the repository at this point in the history
… and removed WSACleanup() when WSAStartup failed.
  • Loading branch information
haakonnessjoen committed May 23, 2014
1 parent 66887fa commit 9a8b9e1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion librouteros.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 9a8b9e1

Please sign in to comment.