aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2018-07-17 21:03:04 +0200
committerToni Uhlig <matzeton@googlemail.com>2018-07-17 21:03:04 +0200
commit3082535650a815ccc42a02eadf85b404ac7813ce (patch)
treedbf1942ec77f0ec0af51c96f759b970cd95c7dbb /src
parent8a507e098b2a42020caa20827992c027f88f6dff (diff)
Coverity CID 301781: fixed resource leak when ioctl fails
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'src')
-rw-r--r--src/socket.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/socket.c b/src/socket.c
index 8c3d9ab..9564caf 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -300,8 +300,10 @@ ssize_t socket_get_ifnames(const psocket *test_sock, char name[][IFNAMSIZ],
ifc.ifc_len = sizeof buf;
ifc.ifc_buf = buf;
- if (ioctl(sock, SIOCGIFCONF, &ifc) == -1)
+ if (ioctl(sock, SIOCGIFCONF, &ifc) == -1) {
+ close(sock);
return -1;
+ }
it = ifc.ifc_req;
end = it + (ifc.ifc_len / sizeof(struct ifreq));