mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
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
This commit is contained in:
parent
c68c5af2dc
commit
75c80b0bda
2 changed files with 5 additions and 0 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
Free the stack allocated in ``va_build_stack`` if ``do_mkstack`` fails and
|
||||||
|
the stack is not a ``small_stack``.
|
|
@ -622,6 +622,9 @@ va_build_stack(PyObject **small_stack, Py_ssize_t small_stack_len,
|
||||||
va_end(lva);
|
va_end(lva);
|
||||||
|
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
|
if (stack != small_stack) {
|
||||||
|
PyMem_Free(stack);
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue