Browse Source

socket_new()成功后,后续函数不成功返回-1,没有删除socket

Keyun-Johan 5 years ago
parent
commit
63e855d78a
1 changed files with 3 additions and 1 deletions
  1. 3 1
      components/net/sal_socket/src/sal_socket.c

+ 3 - 1
components/net/sal_socket/src/sal_socket.c

@@ -917,6 +917,7 @@ int sal_socket(int domain, int type, int protocol)
     socket = socket_new();
     if (socket < 0)
     {
+        socket_delete(socket);
         return -1;
     }
 
@@ -924,6 +925,7 @@ int sal_socket(int domain, int type, int protocol)
     sock = sal_get_socket(socket);
     if (sock == RT_NULL)
     {
+        socket_delete(socket);
         return -1;
     }
 
@@ -956,7 +958,7 @@ int sal_socket(int domain, int type, int protocol)
         sock->user_data = (void *) proto_socket;
         return sock->socket;
     }
-
+    socket_delete(socket);
     return -1;
 }