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 f06a3e2 commit 36ffc93
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
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

0 comments on commit 36ffc93

Please sign in to comment.