Skip to content

Commit

Permalink
Check MMDB_get_metadata_as_entry_data_list return value
Browse files Browse the repository at this point in the history
  • Loading branch information
oschwald committed Jan 23, 2025
1 parent 2a3b007 commit b8f93b4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ History
++++++++++++++++++

* The vendored ``libmaxminddb`` has been updated to 1.12.2.
* The C extension now checks that the database metadata lookup was
successful.

2.6.3 (2025-01-09)
++++++++++++++++++
Expand Down
9 changes: 8 additions & 1 deletion extension/maxminddb.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,14 @@ static PyObject *Reader_metadata(PyObject *self, PyObject *UNUSED(args)) {
}

MMDB_entry_data_list_s *entry_data_list;
MMDB_get_metadata_as_entry_data_list(mmdb_obj->mmdb, &entry_data_list);
int status =
MMDB_get_metadata_as_entry_data_list(mmdb_obj->mmdb, &entry_data_list);
if (status != MMDB_SUCCESS) {
PyErr_Format(MaxMindDB_error,
"Error decoding metadata. %s",
MMDB_strerror(status));
return NULL;
}
MMDB_entry_data_list_s *original_entry_data_list = entry_data_list;

PyObject *metadata_dict = from_entry_data_list(&entry_data_list);
Expand Down

0 comments on commit b8f93b4

Please sign in to comment.