]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Handle error when PyUnicode_GetLength returns a negative value. (GH-28859)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 11 Oct 2021 11:40:57 +0000 (04:40 -0700)
committerGitHub <noreply@github.com>
Mon, 11 Oct 2021 11:40:57 +0000 (04:40 -0700)
(cherry picked from commit 560a79f94e94de66a18f2a5e4194c2fe51e2adf1)

Co-authored-by: Dong-hee Na <donghee.na@python.org>
Python/importdl.c

index b197dfeaef8053cdc295fc5948b96c8dbfc471b6..7f600d4a7aaf8a72274f23e9fd03733b50766899 100644 (file)
@@ -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;