From 6b64a6803e17805a6a4fb9a82f7ec26bdc30a6d5 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 11 Jul 2013 22:50:45 +0200 Subject: [PATCH] Issue #18408: Fix compiler_import() to handle PyUnicode_Substring() failure properly --- Python/compile.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Python/compile.c b/Python/compile.c index 4fc75759260..d11e3abeaa4 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2316,8 +2316,11 @@ compiler_import(struct compiler *c, stmt_ty s) identifier tmp = alias->name; Py_ssize_t dot = PyUnicode_FindChar( alias->name, '.', 0, PyUnicode_GET_LENGTH(alias->name), 1); - if (dot != -1) + if (dot != -1) { tmp = PyUnicode_Substring(alias->name, 0, dot); + if (tmp == NULL) + return 0; + } r = compiler_nameop(c, tmp, Store); if (dot != -1) { Py_DECREF(tmp);