Skip to content

Commit

Permalink
Handle error when PyUnicode_GetLength returns a negative value. (GH-2…
Browse files Browse the repository at this point in the history
…8859)

(cherry picked from commit 560a79f)

Co-authored-by: Dong-hee Na <donghee.na@python.org>
  • Loading branch information
miss-islington and corona10 committed Oct 11, 2021
1 parent 5aca34f commit 56825b6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Python/importdl.c
Expand Up @@ -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;
Expand Down

0 comments on commit 56825b6

Please sign in to comment.