Skip to content

Commit 8177535

Browse files
Ptrskay3messense
authored andcommitted
Py_CompileString decref (#1810)
* 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]>
1 parent b8e932b commit 8177535

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1414
- Restrict FFI definitions `PyGILState_Check` and `Py_tracefunc` to the unlimited API. [#1787](https://github.com/PyO3/pyo3/pull/1787)
1515
- Add missing `_type` field to `PyStatus` struct definition. [#1791](https://github.com/PyO3/pyo3/pull/1791)
1616
- 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)
17-
- Add missing `Py_DECREF` to `Python::run_code` which fixes a memory leak when
18-
calling Python from Rust. [#1806](https://github.com/PyO3/pyo3/pull/1806)
17+
- Add missing `Py_DECREF` to `Python::run_code` and `PyModule::from_code` which fixes a memory leak when
18+
calling Python from Rust. [#1806](https://github.com/PyO3/pyo3/pull/1806), [#1810](https://github.com/PyO3/pyo3/pull/1810)
1919

2020
## [0.14.2] - 2021-08-09
2121

src/types/module.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ impl PyModule {
127127
}
128128

129129
let mptr = ffi::PyImport_ExecCodeModuleEx(module.as_ptr(), cptr, filename.as_ptr());
130+
ffi::Py_DECREF(cptr);
130131
if mptr.is_null() {
131132
return Err(PyErr::fetch(py));
132133
}

0 commit comments

Comments
 (0)