diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2020-09-04 22:56:04 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-04 22:56:04 (GMT) |
commit | 106c1df736d38f5b411a8571b97275d0ecf1d0a9 (patch) | |
tree | f25110dcb686f445ab6a4a9f37683650aada5df1 | |
parent | 8ed1c177c99f6d27bf9f68ce0728f215205eca69 (diff) | |
download | cpython-106c1df736d38f5b411a8571b97275d0ecf1d0a9.zip cpython-106c1df736d38f5b411a8571b97275d0ecf1d0a9.tar.gz cpython-106c1df736d38f5b411a8571b97275d0ecf1d0a9.tar.bz2 |
closes bpo-41533: Fix a potential memory leak when allocating a stack (GH-21847)
Free the stack allocated in va_build_stack if do_mkstack fails
and the stack is not a small_stack
(cherry picked from commit 75c80b0bda89debf312f075716b8c467d411f90e)
Co-authored-by: Tony Solomonik <tony.solomonik@gmail.com>
-rw-r--r-- | Misc/NEWS.d/next/Core and Builtins/2020-08-12-20-29-57.bpo-41533.4pcVAc.rst | 2 | ||||
-rw-r--r-- | Python/modsupport.c | 3 |
2 files changed, 5 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-08-12-20-29-57.bpo-41533.4pcVAc.rst b/Misc/NEWS.d/next/Core and Builtins/2020-08-12-20-29-57.bpo-41533.4pcVAc.rst new file mode 100644 index 0000000..e166f0c --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2020-08-12-20-29-57.bpo-41533.4pcVAc.rst @@ -0,0 +1,2 @@ +Free the stack allocated in ``va_build_stack`` if ``do_mkstack`` fails and +the stack is not a ``small_stack``. diff --git a/Python/modsupport.c b/Python/modsupport.c index 845bdcb..13482c6 100644 --- a/Python/modsupport.c +++ b/Python/modsupport.c @@ -619,6 +619,9 @@ va_build_stack(PyObject **small_stack, Py_ssize_t small_stack_len, va_end(lva); if (res < 0) { + if (stack != small_stack) { + PyMem_Free(stack); + } return NULL; } |