Skip to content

Commit 5433299

Browse files
committed
Check that key was decoded from UTF-8
1 parent fc3c57d commit 5433299

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

extension/maxminddb.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,11 @@ static PyObject *from_map(MMDB_entry_data_list_s **entry_data_list) {
526526
PyObject *key = PyUnicode_FromStringAndSize(
527527
(char *)(*entry_data_list)->entry_data.utf8_string,
528528
(*entry_data_list)->entry_data.data_size);
529+
if (!key) {
530+
// PyUnicode_FromStringAndSize will set an appropriate exception
531+
// in this case.
532+
return NULL;
533+
}
529534

530535
*entry_data_list = (*entry_data_list)->next;
531536

0 commit comments

Comments
 (0)