Commit 4a3f26b2 authored by Dong Anyuan's avatar Dong Anyuan

Fix Coverity Scan CID 340228 (Handle variable s going out of scope leaks the handle.)

parent f6765e06
......@@ -218,6 +218,7 @@ error:
socket_link_t *new_link_udp_client(const char *server, int port){
int s = -1;
socket_link_t *ret = NULL;
ret = calloc(1, sizeof(socket_link_t));
if (ret == NULL) {
......@@ -227,7 +228,6 @@ socket_link_t *new_link_udp_client(const char *server, int port){
ret->socket_fd = -1;
struct sockaddr_in si_other;
int s;
socklen_t slen = sizeof(si_other);
if ( (s=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1){
......@@ -254,8 +254,12 @@ socket_link_t *new_link_udp_client(const char *server, int port){
return ret;
error:
if (ret != NULL) {
close(ret->socket_fd);
free(ret);
ret = NULL;
}
if (s != -1) {
close(s);
s = -1;
}
LOG_E(MAC, "ERROR in new_link_udp_client (see above), returning NULL\n");
return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment