diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2021-10-11 11:40:43 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-11 11:40:43 (GMT) |
commit | 56825b697e0831bf431fd83c59dc5c4d35292560 (patch) | |
tree | 3fbdd89ce6f118ae24df2b0dea05ee69789a1d8f /Python/importdl.c | |
parent | 5aca34f17c4baf8e4882a7e8a827cff06ac6ef25 (diff) | |
download | cpython-56825b697e0831bf431fd83c59dc5c4d35292560.zip cpython-56825b697e0831bf431fd83c59dc5c4d35292560.tar.gz cpython-56825b697e0831bf431fd83c59dc5c4d35292560.tar.bz2 |
Handle error when PyUnicode_GetLength returns a negative value. (GH-28859)
(cherry picked from commit 560a79f94e94de66a18f2a5e4194c2fe51e2adf1)
Co-authored-by: Dong-hee Na <donghee.na@python.org>
Diffstat (limited to 'Python/importdl.c')
-rw-r--r-- | Python/importdl.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Python/importdl.c b/Python/importdl.c index 27ffc64..3d9cd1a 100644 --- a/Python/importdl.c +++ b/Python/importdl.c @@ -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; |