diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2018-04-18 19:57:41 +0200 |
---|---|---|
committer | Pau Espin Pedrol <pespin@sysmocom.de> | 2018-04-18 19:57:44 +0200 |
commit | 15753e93d2eec19e08168e6d049abaa94fbb8d19 (patch) | |
tree | 070c7e1d89c9a651a40a0b76fae1703de4164366 | |
parent | 8fb458667d4efca3def3827c31768f10387a05cb (diff) |
osmo_sockaddr_is_local: Fix memleak
Catched by AddressSanitizer in osmo-bts-trx while running tests in
osmo-gsm-tester:
==31738==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 5744 byte(s) in 1 object(s) allocated from:
#0 0x7ff7ec789ed0 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.3+0xc1ed0)
#1 0x7ff7e952697c (/lib/x86_64-linux-gnu/libc.so.6+0x10297c)
#2 0x7ff7e95274df in getifaddrs (/lib/x86_64-linux-gnu/libc.so.6+0x1034df)
#3 0x7ff7eadcdc8f in osmo_sockaddr_is_local libosmocore/src/socket.c:537
Change-Id: I778d3c1f162abce0595e62670c29c5134bccd28d
-rw-r--r-- | src/socket.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/socket.c b/src/socket.c index d96f664d..cd73f17c 100644 --- a/src/socket.c +++ b/src/socket.c @@ -543,10 +543,13 @@ int osmo_sockaddr_is_local(struct sockaddr *addr, unsigned int addrlen) for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) { if (!ifa->ifa_addr) continue; - if (sockaddr_equal(ifa->ifa_addr, addr, addrlen)) + if (sockaddr_equal(ifa->ifa_addr, addr, addrlen)) { + freeifaddrs(ifaddr); return 1; + } } + freeifaddrs(ifaddr); return 0; } |