free socket fd

call ogs_sock_destroy to free sock when fail to get socket fd
This commit is contained in:
Lester 2022-12-09 14:41:14 +08:00 committed by Sukchan Lee
parent 6ad320a97c
commit bd080f5095
1 changed files with 2 additions and 0 deletions

View File

@ -84,6 +84,8 @@ ogs_sock_t *ogs_sock_socket(int family, int type, int protocol)
sock->family = family;
sock->fd = socket(sock->family, type, protocol);
if (sock->fd < 0) {
ogs_sock_destroy(sock);
ogs_log_message(OGS_LOG_ERROR, ogs_socket_errno,
"socket create(%d:%d:%d) failed", sock->family, type, protocol);
return NULL;