Skip to content

Commit 739a81c

Browse files
Fix Coverity defect
CID 488054 RESOURCE_LEAK Overwriting handle `tunnel.pppd_pty` in `tunnel.pppd_pty = -1` leaks the handle.
1 parent 1dac063 commit 739a81c

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/tunnel.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,10 +1575,9 @@ int run_tunnel(struct vpn_config *config)
15751575
ret = pppd_terminate(&tunnel);
15761576
log_info("Terminated %s.\n", PPP_DAEMON);
15771577
} else {
1578-
if (tunnel.pppd_pty > 0)
1579-
if (tun_close(tunnel.pppd_pty))
1580-
log_error("Cannot properly close tun interface (%d)",
1581-
errno);
1578+
if (tunnel.pppd_pty >= 0 && tun_close(tunnel.pppd_pty))
1579+
log_error("Cannot properly close tun interface (%d)",
1580+
errno);
15821581
tunnel.pppd_pty = -1;
15831582
log_info("Closing tun interface.\n");
15841583
}

0 commit comments

Comments
 (0)