Skip to content

Commit

Permalink
Py_CompileString decref (#1810)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

Co-authored-by: messense <[email protected]>
  • Loading branch information
2 people authored and davidhewitt committed Aug 21, 2021
1 parent b8e932b commit 8177535
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Restrict FFI definitions `PyGILState_Check` and `Py_tracefunc` to the unlimited API. [#1787](https://github.com/PyO3/pyo3/pull/1787)
- Add missing `_type` field to `PyStatus` struct definition. [#1791](https://github.com/PyO3/pyo3/pull/1791)
- Reduce lower bound `num-complex` optional dependency to support interop with `rust-numpy` and `ndarray` when building with the MSRV of 1.41 [#1799](https://github.com/PyO3/pyo3/pull/1799)
- Add missing `Py_DECREF` to `Python::run_code` which fixes a memory leak when
calling Python from Rust. [#1806](https://github.com/PyO3/pyo3/pull/1806)
- Add missing `Py_DECREF` to `Python::run_code` and `PyModule::from_code` which fixes a memory leak when
calling Python from Rust. [#1806](https://github.com/PyO3/pyo3/pull/1806), [#1810](https://github.com/PyO3/pyo3/pull/1810)

## [0.14.2] - 2021-08-09

Expand Down
1 change: 1 addition & 0 deletions src/types/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ impl PyModule {
}

let mptr = ffi::PyImport_ExecCodeModuleEx(module.as_ptr(), cptr, filename.as_ptr());
ffi::Py_DECREF(cptr);
if mptr.is_null() {
return Err(PyErr::fetch(py));
}
Expand Down

0 comments on commit 8177535

Please sign in to comment.