Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dave/more fix missing free #38

Merged
merged 4 commits into from
Jul 21, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@
which did not contain any MMDB metadata. Reported by Federico
G. Schwindt. GitHub issue #36.

* Fixed an error that occurred when passing AI_V4MAPPED to `getaddrinfo()` on
FreeBSD. Apparently this macro is defined but doesn't work the way we
expected it to on that platform.

* Made sure to call `freeaddrinfo()` when a call to `getaddrinfo()` fails but
still allocated memory.

* Fixed a segfault in the tests that occurred on FreeBSD if we passed a NULL
value to `freeaddrinfo()`.

* Added a missing step to the README.md file for installing from our GitHub
repository. Patch by Yasith Fernando.

* Added instructions for installing via Homebrew. Patch by Yasith Fernando.


## 0.5.5 - 2014-03-11

Expand Down
5 changes: 4 additions & 1 deletion src/maxminddb.c
Original file line number Diff line number Diff line change
Expand Up @@ -588,10 +588,13 @@ MMDB_lookup_result_s MMDB_lookup_string(MMDB_s *const mmdb,
}
};

struct addrinfo *addresses;
struct addrinfo *addresses = NULL;
*gai_error = resolve_any_address(ipstr, &addresses);

if (*gai_error) {
if (NULL != addresses) {
freeaddrinfo(addresses);
}
return result;
}

Expand Down
6 changes: 3 additions & 3 deletions t/maxminddb_test_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const char *test_database_path(const char *filename)
}

char *path = malloc(500);
assert(path != NULL);
assert(NULL != path);

snprintf(path, 500, "%s/%s", test_db_dir, filename);

Expand Down Expand Up @@ -149,7 +149,7 @@ MMDB_lookup_result_s lookup_sockaddr_ok(MMDB_s *mmdb, const char *ip,
struct addrinfo hints = {
.ai_socktype = SOCK_STREAM
};
struct addrinfo *addresses;
struct addrinfo *addresses = NULL;

if (ip[0] == ':') {
hints.ai_flags = ai_flags;
Expand All @@ -169,7 +169,7 @@ MMDB_lookup_result_s lookup_sockaddr_ok(MMDB_s *mmdb, const char *ip,
if (gai_error == 0) {
result = MMDB_lookup_sockaddr(mmdb, addresses->ai_addr, &mmdb_error);
}
if (addresses != NULL) {
if (NULL != addresses) {
freeaddrinfo(addresses);
}

Expand Down