From 535c2cdbe7854f4edd9584f40ecac399a8d0ed6a Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Mon, 11 Oct 2021 12:01:07 +0900 Subject: [PATCH] Handle error when PyUnicode_GetLength returns a negative value. --- Python/importdl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Python/importdl.c b/Python/importdl.c index 1847eba74aef45..376cb557000fec 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;