[Python-checkins] Handle error when PyUnicode_GetLength returns a negative value. (GH-28859)

miss-islington webhook-mailer at python.org
Mon Oct 11 07:41:00 EDT 2021


https://github.com/python/cpython/commit/56825b697e0831bf431fd83c59dc5c4d35292560
commit: 56825b697e0831bf431fd83c59dc5c4d35292560
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2021-10-11T04:40:43-07:00
summary:

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

(cherry picked from commit 560a79f94e94de66a18f2a5e4194c2fe51e2adf1)

Co-authored-by: Dong-hee Na <donghee.na at python.org>

files:
M Python/importdl.c

diff --git a/Python/importdl.c b/Python/importdl.c
index 27ffc64284098..3d9cd1ac8673c 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;



More information about the Python-checkins mailing list