From 0287f2f7cbeee90491b24f24da871c981074ac00 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Mon, 27 Jul 2015 07:47:21 -0700 Subject: check return value of PyString_FromStringAndSize for NULL (closes #24734) Patch by Pankaj Sharma. --- Python/compile.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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); -- cgit v0.12