diff options
author | Inada Naoki <songofacandy@gmail.com> | 2023-07-18 03:44:16 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-18 03:44:16 (GMT) |
commit | ece3b9d12a2f47da8b144f185dfba9b2b725fc82 (patch) | |
tree | ee2842b03d9ab8fa3434dc36bd550d88b8fc51d3 /Python/compile.c | |
parent | 1e36ca63f9f5e0399efe13a80499cef290314c2a (diff) | |
download | cpython-ece3b9d12a2f47da8b144f185dfba9b2b725fc82.zip cpython-ece3b9d12a2f47da8b144f185dfba9b2b725fc82.tar.gz cpython-ece3b9d12a2f47da8b144f185dfba9b2b725fc82.tar.bz2 |
gh-106843: fix memleak in _PyCompile_CleanDoc (#106846)
Diffstat (limited to 'Python/compile.c')
-rw-r--r-- | Python/compile.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Python/compile.c b/Python/compile.c index b80f7c0..2a73538 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2267,6 +2267,7 @@ compiler_function_body(struct compiler *c, stmt_ty s, int is_async, Py_ssize_t f } } if (compiler_add_const(c->c_const_cache, c->u, docstring ? docstring : Py_None) < 0) { + Py_XDECREF(docstring); compiler_exit_scope(c); return ERROR; } @@ -8060,7 +8061,9 @@ _PyCompile_CleanDoc(PyObject *doc) } Py_DECREF(doc); - return PyUnicode_FromStringAndSize(buff, w - buff); + PyObject *res = PyUnicode_FromStringAndSize(buff, w - buff); + PyMem_Free(buff); + return res; } |