diff options
author | Roberto Hueso Gómez <rhueso@soleta.eu> | 2019-09-19 12:45:07 +0200 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2019-09-19 16:06:07 +0200 |
commit | 438afb231609894f391f9d42a8a4cee1ab068496 (patch) | |
tree | 8a5749f39b1cd639531734fef41211e3c16ffcc0 | |
parent | 391f9befcb48ae99cf89a067d27e6221339677b9 (diff) |
#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.
-rw-r--r-- | admin/Sources/Services/ogAdmServer/sources/ogAdmServer.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/admin/Sources/Services/ogAdmServer/sources/ogAdmServer.cpp b/admin/Sources/Services/ogAdmServer/sources/ogAdmServer.cpp index 6401fe10..1b806a91 100644 --- a/admin/Sources/Services/ogAdmServer/sources/ogAdmServer.cpp +++ b/admin/Sources/Services/ogAdmServer/sources/ogAdmServer.cpp @@ -4356,6 +4356,7 @@ static int og_socket_server_init(const char *port) local.sin_port = htons(atoi(port)); if (bind(sd, (struct sockaddr *) &local, sizeof(local)) < 0) { + close(sd); syslog(LOG_ERR, "cannot bind socket\n"); return -1; } |