Skip to content

Commit 63e855d

Browse files
committed
socket_new()成功后,后续函数不成功返回-1,没有删除socket
1 parent 00f5094 commit 63e855d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

components/net/sal_socket/src/sal_socket.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -917,13 +917,15 @@ int sal_socket(int domain, int type, int protocol)
917917
socket = socket_new();
918918
if (socket < 0)
919919
{
920+
socket_delete(socket);
920921
return -1;
921922
}
922923

923924
/* get sal socket object by socket descriptor */
924925
sock = sal_get_socket(socket);
925926
if (sock == RT_NULL)
926927
{
928+
socket_delete(socket);
927929
return -1;
928930
}
929931

@@ -956,7 +958,7 @@ int sal_socket(int domain, int type, int protocol)
956958
sock->user_data = (void *) proto_socket;
957959
return sock->socket;
958960
}
959-
961+
socket_delete(socket);
960962
return -1;
961963
}
962964

0 commit comments

Comments
 (0)