summaryrefslogtreecommitdiff
path: root/Python/compile.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-07-11 22:50:45 +0200
committerVictor Stinner <victor.stinner@gmail.com>2013-07-11 22:50:45 +0200
commit3d0056f5b1d38eeecacd4e905a25d9ff0130e322 (patch)
treed4ceb0b8d38f301660764ca5256f6139cfd1ee7e /Python/compile.c
parentec1218faf67f13f151aac35ef29ff69fde58256f (diff)
downloadcpython-3d0056f5b1d38eeecacd4e905a25d9ff0130e322.tar.gz
Issue #18408: Fix compiler_import() to handle PyUnicode_Substring() failure properly
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 4fc7575926..d11e3abeaa 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);