summaryrefslogtreecommitdiffstats
path: root/Tools/peg_generator
diff options
context:
space:
mode:
authorPablo Galindo Salgado <Pablogsal@gmail.com>2023-01-16 18:45:37 (GMT)
committerGitHub <noreply@github.com>2023-01-16 18:45:37 (GMT)
commit1de4395f62bb140563761ef5cbdf46accef3c550 (patch)
tree9186fb64a869592f9f9c46b0dfb9e532e5e43790 /Tools/peg_generator
parent30753c37c6d00929af6afb5e0bc20bed4656d6b6 (diff)
downloadcpython-1de4395f62bb140563761ef5cbdf46accef3c550.zip
cpython-1de4395f62bb140563761ef5cbdf46accef3c550.tar.gz
cpython-1de4395f62bb140563761ef5cbdf46accef3c550.tar.bz2
gh-101046: Fix a potential memory leak in the parser when raising MemoryError (#101051)
Diffstat (limited to 'Tools/peg_generator')
-rw-r--r--Tools/peg_generator/pegen/c_generator.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/Tools/peg_generator/pegen/c_generator.py b/Tools/peg_generator/pegen/c_generator.py
index 31bb505..c41d87b 100644
--- a/Tools/peg_generator/pegen/c_generator.py
+++ b/Tools/peg_generator/pegen/c_generator.py
@@ -801,7 +801,7 @@ class CParserGenerator(ParserGenerator, GrammarVisitor):
self.print(
"void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));"
)
- self.out_of_memory_return(f"!_new_children")
+ self.out_of_memory_return(f"!_new_children", cleanup_code="PyMem_Free(_children);")
self.print("_children = _new_children;")
self.print("}")
self.print("_children[_n++] = _res;")