summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorTony Solomonik <tony.solomonik@gmail.com>2020-08-30 04:53:08 (GMT)
committerGitHub <noreply@github.com>2020-08-30 04:53:08 (GMT)
commit75c80b0bda89debf312f075716b8c467d411f90e (patch)
tree3b013c3da2528cb7a3760a40746685f898d367ea /Python
parentc68c5af2dc5ada8875a662f2beaac6234eae2a5a (diff)
downloadcpython-75c80b0bda89debf312f075716b8c467d411f90e.zip
cpython-75c80b0bda89debf312f075716b8c467d411f90e.tar.gz
cpython-75c80b0bda89debf312f075716b8c467d411f90e.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
Diffstat (limited to 'Python')
-rw-r--r--Python/modsupport.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/Python/modsupport.c b/Python/modsupport.c
index 2637039..2dabcf3 100644
--- a/Python/modsupport.c
+++ b/Python/modsupport.c
@@ -622,6 +622,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;
}