Skip to content
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

Py_CompileString decref #1810

Merged
merged 5 commits into from
Aug 18, 2021
Merged

Conversation

Ptrskay3
Copy link
Contributor

This PR adds the missing Py_DECREF to PyModule::from_code similar to #1806. Py_CompileString returns a new owned pointer, and its reference count should be decremented, thus it's deallocated corretly.

This should close #1801.

CHANGELOG.md Outdated Show resolved Hide resolved
@Ptrskay3 Ptrskay3 changed the title Py compilestring decref Py_CompileString decref Aug 18, 2021
Copy link
Member

@messense messense left a comment

Choose a reason for hiding this comment

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

Thanks!

src/types/module.rs Show resolved Hide resolved
src/types/module.rs Outdated Show resolved Hide resolved
Co-authored-by: messense <messense@icloud.com>
Copy link
Member

@messense messense left a comment

Choose a reason for hiding this comment

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

LGTM

@messense messense enabled auto-merge (squash) August 18, 2021 10:49
@messense messense merged commit f72b2c8 into PyO3:main Aug 18, 2021
@mejrs mejrs mentioned this pull request Aug 20, 2021
davidhewitt pushed a commit that referenced this pull request Aug 21, 2021
* update changelog

* fix memory leak in PyModule::from_code

* add PR link to changelog

* Add Py_DECREF also when PyImport_ExecCodeModuleEx fails

* Remove duplicated calls, simplify logic

Co-authored-by: messense <messense@icloud.com>

Co-authored-by: messense <messense@icloud.com>
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.

Potential memory leak when calling Python from Rust
3 participants