diff --git a/src/pc/protocols/tcpip_host.cpp b/src/pc/protocols/tcpip_host.cpp index 4e6baa1..8b40fe6 100644 --- a/src/pc/protocols/tcpip_host.cpp +++ b/src/pc/protocols/tcpip_host.cpp @@ -1095,11 +1095,15 @@ int tcpipPlatformConnect(const char *devPathRead, const char *devPathWrite, void const size_t maxlen = 255; size_t len = strnlen(devPathWrite, maxlen + 1); - if (len == 0 || len >= maxlen + 1) + if (len == 0 || len >= maxlen + 1) { + tcpip_close_socket(sock); return X_LINK_PLATFORM_INVALID_PARAMETERS; + } char *const serv_ip = (char *)malloc(len + 1); - if (!serv_ip) + if (!serv_ip) { + tcpip_close_socket(sock); return X_LINK_PLATFORM_ERROR; + } serv_ip[0] = 0; // Parse port if specified, or use default int port = TCPIP_LINK_SOCKET_PORT; @@ -1188,13 +1192,17 @@ int tcpipPlatformClose(void *fdKey) TCPIP_SOCKET sock = (TCPIP_SOCKET) (uintptr_t) tmpsockfd; #ifdef _WIN32 - status = shutdown(sock, SD_BOTH); - if (status == 0) { status = closesocket(sock); } + if(shutdown(sock, SD_BOTH)) { + mvLog(MVLOG_DEBUG, "Error shutting down socket: %d", tcpip_errno); + } + status = closesocket(sock); #else if(sock != -1) { - status = shutdown(sock, SHUT_RDWR); - if (status == 0) { status = close(sock); } + if(shutdown(sock, SHUT_RDWR)) { + mvLog(MVLOG_DEBUG, "Error shutting down socket: %d", tcpip_errno); + } + status = close(sock); } #endif