From be62b8a179e4b05cd25fdc54733e5e26db959975 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Fri, 2 Feb 2018 16:30:43 +0100 Subject: [PATCH] Fixed uninitialized sock --- srsenb/test/upper/ip_test.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/srsenb/test/upper/ip_test.cc b/srsenb/test/upper/ip_test.cc index 820974b4d..e1edf981b 100644 --- a/srsenb/test/upper/ip_test.cc +++ b/srsenb/test/upper/ip_test.cc @@ -591,7 +591,7 @@ int main(int argc, char *argv[]) int setup_if_addr(char *ip_addr) { char *dev = (char*) "tun_srsenb"; - int sock; + int sock = -1; // Construct the TUN device int tun_fd = open("/dev/net/tun", O_RDWR); @@ -647,7 +647,11 @@ int setup_if_addr(char *ip_addr) return(tun_fd); clean_exit: - shutdown(sock, SHUT_RDWR); - close(tun_fd); + if (sock != -1) { + shutdown(sock, SHUT_RDWR); + } + if (tun_fd != -1) { + close(tun_fd); + } return SRSLTE_ERROR; }