check return value of PyString_FromStringAndSize for NULL (closes #24734)

Patch by Pankaj Sharma.
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 @@
             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);