Skip to content

Commit 0287f2f

Browse files
committed
check return value of PyString_FromStringAndSize for NULL (closes #24734)
Patch by Pankaj Sharma.
1 parent 581234e commit 0287f2f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Python/compile.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1979,9 +1979,12 @@ compiler_import(struct compiler *c, stmt_ty s)
19791979
identifier tmp = alias->name;
19801980
const char *base = PyString_AS_STRING(alias->name);
19811981
char *dot = strchr(base, '.');
1982-
if (dot)
1982+
if (dot) {
19831983
tmp = PyString_FromStringAndSize(base,
19841984
dot - base);
1985+
if (tmp == NULL)
1986+
return 0;
1987+
}
19851988
r = compiler_nameop(c, tmp, Store);
19861989
if (dot) {
19871990
Py_DECREF(tmp);

0 commit comments

Comments
 (0)