]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Handle error when PyUnicode_GetLength returns a negative value. (GH-28859)
authorDong-hee Na <donghee.na@python.org>
Mon, 11 Oct 2021 11:08:38 +0000 (20:08 +0900)
committerGitHub <noreply@github.com>
Mon, 11 Oct 2021 11:08:38 +0000 (20:08 +0900)
Python/importdl.c

index 27ffc64284098e6e8e2435a842264a9be202587a..3d9cd1ac8673cc05077318993c7b09c67f08069f 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;