]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
check return value of PyString_FromStringAndSize for NULL (closes #24734)
authorBenjamin Peterson <benjamin@python.org>
Mon, 27 Jul 2015 14:47:21 +0000 (07:47 -0700)
committerBenjamin Peterson <benjamin@python.org>
Mon, 27 Jul 2015 14:47:21 +0000 (07:47 -0700)
Patch by Pankaj Sharma.

Python/compile.c

index e871d380fc483a92a12736ebd4ab2b48c53ca884..290075763a69e1f03335fcbec0641732ba13f0b1 100644 (file)
@@ -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);