Skip to content

Commit 5996892

Browse files
committed
RTSDK-5606 Fixed the ipcShutdownSckt(void* transport) and ipcCloseSckt(void *transport) to ensure that the transport pointer is valid before getting its FD.
1 parent 3753741 commit 5996892

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

Cpp-C/Eta/Impl/Transport/ripcutils.c

+18-10
Original file line numberDiff line numberDiff line change
@@ -1040,26 +1040,34 @@ int ipcWrite( void *transport, char *buf, int outLen, ripcRWFlags flags, RsslErr
10401040
to be read by the other side prior to closing the connection. */
10411041
int ipcShutdownSckt(void* transport)
10421042
{
1043-
/* If the socket is invalid, it already has been closed by curl */
1044-
if (((ripcSocketSession*)transport)->fd != RIPC_INVALID_SOCKET)
1045-
shutdown(((ripcSocketSession*)transport)->fd, shutdownFlag);
1043+
if (transport != NULL)
1044+
{
1045+
/* If the socket is invalid, it already has been closed by curl */
1046+
if (((ripcSocketSession*)transport)->fd != RIPC_INVALID_SOCKET)
1047+
shutdown(((ripcSocketSession*)transport)->fd, shutdownFlag);
1048+
1049+
((ripcSocketSession*)transport)->fd = RIPC_INVALID_SOCKET;
10461050

1047-
((ripcSocketSession*)transport)->fd = RIPC_INVALID_SOCKET;
1051+
free(transport);
1052+
}
10481053

1049-
free(transport);
10501054
return(1);
10511055
}
10521056

10531057

10541058
int ipcCloseSckt(void *transport)
10551059
{
1056-
/* If the socket is invalid, it already has been closed by curl */
1057-
if(((ripcSocketSession*)transport)->fd != RIPC_INVALID_SOCKET)
1058-
sock_close(((ripcSocketSession*)transport)->fd);
1060+
if (transport != NULL)
1061+
{
1062+
/* If the socket is invalid, it already has been closed by curl */
1063+
if (((ripcSocketSession*)transport)->fd != RIPC_INVALID_SOCKET)
1064+
sock_close(((ripcSocketSession*)transport)->fd);
1065+
1066+
((ripcSocketSession*)transport)->fd = RIPC_INVALID_SOCKET;
10591067

1060-
((ripcSocketSession*)transport)->fd = RIPC_INVALID_SOCKET;
1068+
free(transport);
1069+
}
10611070

1062-
free(transport);
10631071
return(1);
10641072
}
10651073

0 commit comments

Comments
 (0)