Skip to content

Commit b8f93b4

Browse files
committed
Check MMDB_get_metadata_as_entry_data_list return value
1 parent 2a3b007 commit b8f93b4

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Diff for: HISTORY.rst

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ History
77
++++++++++++++++++
88

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

1113
2.6.3 (2025-01-09)
1214
++++++++++++++++++

Diff for: extension/maxminddb.c

+8-1
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,14 @@ static PyObject *Reader_metadata(PyObject *self, PyObject *UNUSED(args)) {
351351
}
352352

353353
MMDB_entry_data_list_s *entry_data_list;
354-
MMDB_get_metadata_as_entry_data_list(mmdb_obj->mmdb, &entry_data_list);
354+
int status =
355+
MMDB_get_metadata_as_entry_data_list(mmdb_obj->mmdb, &entry_data_list);
356+
if (status != MMDB_SUCCESS) {
357+
PyErr_Format(MaxMindDB_error,
358+
"Error decoding metadata. %s",
359+
MMDB_strerror(status));
360+
return NULL;
361+
}
355362
MMDB_entry_data_list_s *original_entry_data_list = entry_data_list;
356363

357364
PyObject *metadata_dict = from_entry_data_list(&entry_data_list);

0 commit comments

Comments
 (0)