summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2020-09-04 22:26:05 (GMT)
committerGitHub <noreply@github.com>2020-09-04 22:26:05 (GMT)
commit66e9c2aee4af846ab1b77faa8a46fe3a9373d943 (patch)
tree112e1473d54c26b8e14e2e8a9676cef6197657c2 /Python
parente52f5bc898c9a11fb1d57a42a1f9ec60b424d576 (diff)
downloadcpython-66e9c2aee4af846ab1b77faa8a46fe3a9373d943.zip
cpython-66e9c2aee4af846ab1b77faa8a46fe3a9373d943.tar.gz
cpython-66e9c2aee4af846ab1b77faa8a46fe3a9373d943.tar.bz2
[3.8] closes bpo-41533: Fix a potential memory leak when allocating a stack (GH-21847) (GH-22015)
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>
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 7271af3..5062811 100644
--- a/Python/modsupport.c
+++ b/Python/modsupport.c
@@ -618,6 +618,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;
}