mirror of https://git.48k.eu/ogserver
#915: Fix file descriptor leak in og_socket_server_init() from exit path
Call close() to release the socket in the event of an error.
infer says:
sources/ogAdmServer.cpp:1244: error: RESOURCE_LEAK
resource acquired by call to `socket()` at line 1236, column 6 is not released after line 1244, column 3.
1242. sizeof(on));
1243. if (res < 0) {
1244. > syslog(LOG_ERR, "cannot set broadcast socket\n");
1245. return false;
1246. }
Not a real problem since OS releases process resources if the server
cannot bind to the port, but just to be correct here.
master
parent
c1c89e196c
commit
8b1beddbe4
|
|
@ -4356,6 +4356,7 @@ static int og_socket_server_init(const char *port)
|
||||||
local.sin_port = htons(atoi(port));
|
local.sin_port = htons(atoi(port));
|
||||||
|
|
||||||
if (bind(sd, (struct sockaddr *) &local, sizeof(local)) < 0) {
|
if (bind(sd, (struct sockaddr *) &local, sizeof(local)) < 0) {
|
||||||
|
close(sd);
|
||||||
syslog(LOG_ERR, "cannot bind socket\n");
|
syslog(LOG_ERR, "cannot bind socket\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue