Skip to content

gh-101046: Fix a potential memory leak in the parser when raising MemoryError #101051

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 16, 2023

Conversation

pablogsal
Copy link
Member

@pablogsal pablogsal commented Jan 15, 2023

@@ -801,7 +801,7 @@ def handle_alt_loop(self, node: Alt, is_gather: bool, rulename: Optional[str]) -
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);")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.out_of_memory_return(f"!new_children", cleanup_code="PyMem_Free(_children);")
self.out_of_memory_return(f"!_new_children", cleanup_code="PyMem_Free(_children);")

Copy link
Member

@lysnikolaou lysnikolaou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@pablogsal pablogsal merged commit 1de4395 into python:main Jan 16, 2023
@pablogsal pablogsal deleted the gh-101046 branch January 16, 2023 18:45
@miss-islington
Copy link
Contributor

Thanks @pablogsal for the PR 🌮🎉.. I'm working now to backport this PR to: 3.9, 3.10, 3.11.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Sorry, @pablogsal, I could not cleanly backport this to 3.11 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 1de4395f62bb140563761ef5cbdf46accef3c550 3.11

@miss-islington
Copy link
Contributor

Sorry @pablogsal, I had trouble checking out the 3.10 backport branch.
Please retry by removing and re-adding the "needs backport to 3.10" label.
Alternatively, you can backport using cherry_picker on the command line.
cherry_picker 1de4395f62bb140563761ef5cbdf46accef3c550 3.10

@miss-islington
Copy link
Contributor

Sorry, @pablogsal, I could not cleanly backport this to 3.9 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 1de4395f62bb140563761ef5cbdf46accef3c550 3.9

pablogsal added a commit to pablogsal/cpython that referenced this pull request Jan 16, 2023
…n raising MemoryError (pythonGH-101051).

(cherry picked from commit 1de4395)

Co-authored-by: Pablo Galindo Salgado <[email protected]>
@bedevere-bot
Copy link

GH-101085 is a backport of this pull request to the 3.11 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Jan 16, 2023
pablogsal added a commit to pablogsal/cpython that referenced this pull request Jan 16, 2023
…n raising MemoryError (pythonGH-101051).

(cherry picked from commit 1de4395)

Co-authored-by: Pablo Galindo Salgado <[email protected]>
@bedevere-bot
Copy link

GH-101086 is a backport of this pull request to the 3.10 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Jan 16, 2023
pablogsal added a commit that referenced this pull request Jan 16, 2023
pablogsal added a commit that referenced this pull request Jan 16, 2023
@hugovk
Copy link
Member

hugovk commented Feb 18, 2025

Sorry, @pablogsal, I could not cleanly backport this to 3.9 due to a conflict. Please backport using cherry_picker on command line. cherry_picker 1de4395f62bb140563761ef5cbdf46accef3c550 3.9

@pablogsal Does this still need backporting to 3.9? Otherwise let's remove the backport label.

@pablogsal pablogsal removed the needs backport to 3.9 only security fixes label Feb 18, 2025
@pablogsal
Copy link
Member Author

Removed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants