From 618f708de054186fe247069f16a5c8a5514ab7f6 Mon Sep 17 00:00:00 2001 From: Kirill Podoprigora Date: Thu, 20 Jul 2023 21:00:21 +0300 Subject: [PATCH 1/2] gh-106916: Add missing error check --- Python/compile.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Python/compile.c b/Python/compile.c index d5405b46561820..a1c39fe42a2ff4 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -8053,6 +8053,11 @@ _PyCompile_CleanDoc(PyObject *doc) } char *buff = PyMem_Malloc(doc_size); + if (buff == NULL){ + PyErr_NoMemory(); + return NULL; + } + char *w = buff; while (p < pend) { From dda0d86d2122d829828cc82f9742c0c06e10d2f0 Mon Sep 17 00:00:00 2001 From: Kirill Podoprigora Date: Thu, 20 Jul 2023 23:24:34 +0300 Subject: [PATCH 2/2] Update Python/compile.c Co-authored-by: Serhiy Storchaka --- Python/compile.c | 1 + 1 file changed, 1 insertion(+) diff --git a/Python/compile.c b/Python/compile.c index a1c39fe42a2ff4..9a13ab525d8a47 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -8054,6 +8054,7 @@ _PyCompile_CleanDoc(PyObject *doc) char *buff = PyMem_Malloc(doc_size); if (buff == NULL){ + Py_DECREF(doc); PyErr_NoMemory(); return NULL; }