From 8fd19eefa46b313673d6ba2a0194a68674ef5ea9 Mon Sep 17 00:00:00 2001 From: Vadim Kochan Date: Sat, 4 Feb 2017 11:56:14 +0200 Subject: geoip: Fix memory leak when using GeoIPRecord GeoIP_record_by_ipnum{,_v6} returns allocated pointer to GeoIPRecord with allocated city, region & postal_code which is not freed after the call. Fixed by xstrdup-ing required GeoIPRecord member (city/region) and after calling GeoIPRecord_delete to free the geoip record. Of course it is needed to also free obtained city/region in netsniff-ng, astraceroute & flowtop tools. Fixes #169 Signed-off-by: Vadim Kochan Signed-off-by: Tobias Klauser --- flowtop.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'flowtop.c') diff --git a/flowtop.c b/flowtop.c index 2491de7..1caae9e 100644 --- a/flowtop.c +++ b/flowtop.c @@ -682,7 +682,7 @@ flow_entry_geo_city_lookup_generic(struct flow_entry *n, { struct sockaddr_in sa4; struct sockaddr_in6 sa6; - const char *city = NULL; + char *city = NULL; switch (n->l3_proto) { default: @@ -706,6 +706,8 @@ flow_entry_geo_city_lookup_generic(struct flow_entry *n, sizeof(n->city_src)); else SELFLD(dir, city_src, city_dst)[0] = '\0'; + + free(city); } static void -- cgit v1.2.3-54-g00ecf