Permalink
Browse files

Merge pull request #9 from mihau/master

Free memory pointed by record once it is not used anymore
  • Loading branch information...
2 parents 7de9690 + 76cac7f commit 1b9f1d140642b76f5e9f6e1d3f8de31b9dea001c @cosimo committed Feb 15, 2016
Showing with 6 additions and 0 deletions.
  1. +6 −0 geoip.c
View
@@ -57,6 +57,7 @@ static int geoip_lookup(vcl_string *ip, vcl_string *resolved) {
record->longitude,
ip
);
+ free(record);
}
/* Failed lookup */
@@ -90,6 +91,7 @@ static int geoip_lookup_country(vcl_string *ip, vcl_string *resolved) {
: FALLBACK_COUNTRY
);
+ free(record);
pthread_mutex_unlock(&geoip_mutex);
/* Assume always success: we have FALLBACK_COUNTRY */
@@ -149,6 +151,10 @@ int main(int argc, char **argv) {
geoip_lookup(argv[1], resolved);
}
printf("%s\n", resolved);
+
+ GeoIP_delete(gi);
+ gi = NULL;
+
return 0;
}
#endif /* __VCL__ */

0 comments on commit 1b9f1d1

Please sign in to comment.