[Python-checkins] gh-106916: Add missing error check _PyCompile_CleanDoc (#106921)

methane webhook-mailer at python.org
Fri Jul 21 00:57:02 EDT 2023


https://github.com/python/cpython/commit/85ed1d24427bf3e000467aab7ee1b0322b0a9013
commit: 85ed1d24427bf3e000467aab7ee1b0322b0a9013
branch: main
author: Kirill Podoprigora <kirill.bast9 at mail.ru>
committer: methane <songofacandy at gmail.com>
date: 2023-07-21T13:56:58+09:00
summary:

gh-106916: Add missing error check _PyCompile_CleanDoc (#106921)

Co-authored-by: Serhiy Storchaka <storchaka at gmail.com>

files:
M Python/compile.c

diff --git a/Python/compile.c b/Python/compile.c
index d5405b4656182..9a13ab525d8a4 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) {



More information about the Python-checkins mailing list