summaryrefslogtreecommitdiffstats
path: root/Python/compile.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2015-07-27 14:47:21 (GMT)
committerBenjamin Peterson <benjamin@python.org>2015-07-27 14:47:21 (GMT)
commit0287f2f7cbeee90491b24f24da871c981074ac00 (patch)
tree58c401b526dc1a8de358669cce18db19d837e0d2 /Python/compile.c
parent581234ee0d2612fbbc9e521e1bcb3a6d48050dc8 (diff)
downloadcpython-0287f2f7cbeee90491b24f24da871c981074ac00.zip
cpython-0287f2f7cbeee90491b24f24da871c981074ac00.tar.gz
cpython-0287f2f7cbeee90491b24f24da871c981074ac00.tar.bz2
check return value of PyString_FromStringAndSize for NULL (closes #24734)
Patch by Pankaj Sharma.
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 e871d38..2900757 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -1979,9 +1979,12 @@ compiler_import(struct compiler *c, stmt_ty s)
identifier tmp = alias->name;
const char *base = PyString_AS_STRING(alias->name);
char *dot = strchr(base, '.');
- if (dot)
+ if (dot) {
tmp = PyString_FromStringAndSize(base,
dot - base);
+ if (tmp == NULL)
+ return 0;
+ }
r = compiler_nameop(c, tmp, Store);
if (dot) {
Py_DECREF(tmp);