diff options
author | Dario Lombardo <lomato@gmail.com> | 2017-02-22 09:54:53 +0100 |
---|---|---|
committer | João Valverde <j@v6e.pt> | 2017-02-22 23:20:15 +0000 |
commit | 67f4673ce5af374b74994c8a8c488aab4dbfdca0 (patch) | |
tree | 1aab0a7f29aa39a92b4ee3eabddfdb555545a06c /epan | |
parent | 785a0d8e75560a9a8733f667751ea403f6400d53 (diff) | |
download | wireshark-67f4673ce5af374b74994c8a8c488aab4dbfdca0.tar.gz |
geoip_db: replace g_free with free.
Fix also a const cast by using the proper constness.
Change-Id: Ifcf1854051c7f5dec911331d9cfc809e6b2dd42e
Reviewed-on: https://code.wireshark.org/review/20246
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Reviewed-by: João Valverde <j@v6e.pt>
Diffstat (limited to 'epan')
-rw-r--r-- | epan/geoip_db.c | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/epan/geoip_db.c b/epan/geoip_db.c index 59895e012f..f89fd41781 100644 --- a/epan/geoip_db.c +++ b/epan/geoip_db.c @@ -48,6 +48,10 @@ /* This needs to match NUM_GEOIP_COLS in hostlist_table.h */ #define MAX_GEOIP_DBS 13 +#ifndef GeoIP_free +#define GeoIP_free free +#endif + /* Column names for each database type */ value_string geoip_type_name_vals[] = { { GEOIP_COUNTRY_EDITION, "Country" }, @@ -337,7 +341,8 @@ char * geoip_db_lookup_ipv4(guint dbnum, guint32 addr, const char *not_found) { GeoIP *gi; GeoIPRecord *gir; - const char *raw_val; + char *name; + const char *country; char *val, *ret = NULL; if (dbnum > geoip_db_num_dbs()) { @@ -350,9 +355,9 @@ geoip_db_lookup_ipv4(guint dbnum, guint32 addr, const char *not_found) { if (gi) { switch (gi->databaseType) { case GEOIP_COUNTRY_EDITION: - raw_val = GeoIP_country_name_by_ipnum(gi, addr); - if (raw_val) { - ret = db_val_to_utf_8(raw_val, gi); + country = GeoIP_country_name_by_ipnum(gi, addr); + if (country) { + ret = db_val_to_utf_8(country, gi); } break; @@ -373,10 +378,10 @@ geoip_db_lookup_ipv4(guint dbnum, guint32 addr, const char *not_found) { case GEOIP_ORG_EDITION: case GEOIP_ISP_EDITION: case GEOIP_ASNUM_EDITION: - raw_val = GeoIP_name_by_ipnum(gi, addr); - if (raw_val) { - ret = db_val_to_utf_8(raw_val, gi); - g_free((char*)raw_val); + name = GeoIP_name_by_ipnum(gi, addr); + if (name) { + ret = db_val_to_utf_8(name, gi); + GeoIP_free(name); } break; @@ -464,7 +469,8 @@ char * geoip_db_lookup_ipv6(guint dbnum, struct e_in6_addr addr, const char *not_found) { GeoIP *gi; geoipv6_t gaddr; - const char *raw_val; + char *name; + const char *country; char *val, *ret = NULL; #if NUM_DB_TYPES > 31 GeoIPRecord *gir; @@ -482,9 +488,9 @@ geoip_db_lookup_ipv6(guint dbnum, struct e_in6_addr addr, const char *not_found) if (gi) { switch (gi->databaseType) { case GEOIP_COUNTRY_EDITION_V6: - raw_val = GeoIP_country_name_by_ipnum_v6(gi, gaddr); - if (raw_val) { - ret = db_val_to_utf_8(raw_val, gi); + country = GeoIP_country_name_by_ipnum_v6(gi, gaddr); + if (country) { + ret = db_val_to_utf_8(country, gi); } break; @@ -504,10 +510,10 @@ geoip_db_lookup_ipv6(guint dbnum, struct e_in6_addr addr, const char *not_found) case GEOIP_ORG_EDITION_V6: case GEOIP_ISP_EDITION_V6: case GEOIP_ASNUM_EDITION_V6: - raw_val = GeoIP_name_by_ipnum_v6(gi, gaddr); - if (raw_val) { - ret = db_val_to_utf_8(raw_val, gi); - g_free((char*)raw_val); + name = GeoIP_name_by_ipnum_v6(gi, gaddr); + if (name) { + ret = db_val_to_utf_8(name, gi); + GeoIP_free(name); } break; #endif /* NUM_DB_TYPES */ |