From 273484365870c26f4c64af036abff5a081238f30 Mon Sep 17 00:00:00 2001 From: Arjun Date: Tue, 5 Nov 2024 08:30:21 +0530 Subject: [PATCH] fix: memory leak in MMDB_open() Signed-off-by: Arjun --- src/maxminddb.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/maxminddb.c b/src/maxminddb.c index 55a3ce20..c7e75423 100644 --- a/src/maxminddb.c +++ b/src/maxminddb.c @@ -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; } @@ -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; } @@ -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; }