Handle error when PyUnicode_GetLength returns a negative value. (GH-28859)

This commit is contained in:
Dong-hee Na 2021-10-11 20:08:38 +09:00 committed by GitHub
parent ab62051152
commit 560a79f94e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -42,6 +42,9 @@ get_encoded_name(PyObject *name, const char **hook_prefix) {
/* Get the short name (substring after last dot) */
name_len = PyUnicode_GetLength(name);
if (name_len < 0) {
return NULL;
}
lastdot = PyUnicode_FindChar(name, '.', 0, name_len, -1);
if (lastdot < -1) {
return NULL;