diff --git a/Python/compile.c b/Python/compile.c index d5405b46561..9a13ab525d8 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -8053,6 +8053,12 @@ _PyCompile_CleanDoc(PyObject *doc) } char *buff = PyMem_Malloc(doc_size); + if (buff == NULL){ + Py_DECREF(doc); + PyErr_NoMemory(); + return NULL; + } + char *w = buff; while (p < pend) {