Skip to content

Commit 560a79f

Browse files
authored
Handle error when PyUnicode_GetLength returns a negative value. (GH-28859)
1 parent ab62051 commit 560a79f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Python/importdl.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ get_encoded_name(PyObject *name, const char **hook_prefix) {
4242

4343
/* Get the short name (substring after last dot) */
4444
name_len = PyUnicode_GetLength(name);
45+
if (name_len < 0) {
46+
return NULL;
47+
}
4548
lastdot = PyUnicode_FindChar(name, '.', 0, name_len, -1);
4649
if (lastdot < -1) {
4750
return NULL;

0 commit comments

Comments
 (0)