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

Check MMDB_get_metadata_as_entry_data_list return value #178

Merged
merged 3 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ CHANGELOG
* Improve the error handling when the user tries to open a directory
with the pure PHP reader.
* Improve the typehints on arrays in the PHPDocs.
* The C extension now checks that the database metadata lookup was
successful.

1.11.1 (2023-12-01)
-------------------
Expand Down
10 changes: 9 additions & 1 deletion ext/maxminddb.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,15 @@ PHP_METHOD(MaxMind_Db_Reader, metadata) {
object_init_ex(return_value, metadata_ce);

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) {
zend_throw_exception_ex(maxminddb_exception_ce,
0 TSRMLS_CC,
"Error while decoding metadata. %s",
MMDB_strerror(status));
return;
}

zval metadata_array;
const MMDB_entry_data_list_s *rv =
Expand Down