summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-10-11 04:40:57 -0700
committerGitHub <noreply@github.com>2021-10-11 04:40:57 -0700
commit7d1ae89b846c6965f7e0de1cc01a89db90c2667a (patch)
treeaa58c726de8c56a4614fda77c800d43e2abf9851
parentac421c348bf422f9a0d85fe0a1de3fa3f4886650 (diff)
downloadcpython-git-7d1ae89b846c6965f7e0de1cc01a89db90c2667a.tar.gz
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>
-rw-r--r--Python/importdl.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/Python/importdl.c b/Python/importdl.c
index b197dfeaef..7f600d4a7a 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;