Skip to content

Commit

Permalink
fix: memory leak in MMDB_open()
Browse files Browse the repository at this point in the history
Signed-off-by: Arjun <[email protected]>
  • Loading branch information
pkillarjun committed Nov 5, 2024
1 parent 0fd8898 commit 2734843
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/maxminddb.c
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,8 @@ static int populate_languages_metadata(MMDB_s *mmdb,
MMDB_entry_data_list_s *member;
status = MMDB_get_entry_data_list(&array_start, &member);
if (MMDB_SUCCESS != status) {
if (MMDB_OUT_OF_MEMORY_ERROR != status)
MMDB_free_entry_data_list(member);
return status;
}

Expand All @@ -750,6 +752,7 @@ static int populate_languages_metadata(MMDB_s *mmdb,
for (uint32_t i = 0; i < array_size; i++) {
member = member->next;
if (MMDB_DATA_TYPE_UTF8_STRING != member->entry_data.type) {
MMDB_free_entry_data_list(first_member);
return MMDB_INVALID_METADATA_ERROR;
}

Expand Down Expand Up @@ -795,6 +798,8 @@ static int populate_description_metadata(MMDB_s *mmdb,
" status = %d (%s)",
status,
MMDB_strerror(status));
if (MMDB_OUT_OF_MEMORY_ERROR != status)
MMDB_free_entry_data_list(member);
return status;
}

Expand Down

0 comments on commit 2734843

Please sign in to comment.