Skip to content

Commit

Permalink
backport fix the memory leak in fixedpool (#9272) (#9309)
Browse files Browse the repository at this point in the history
* fix the memory leak in fixedpool (#9272)

* fix the memory leak in fixedpool

fixes #9255

* simplify fix

* resolve clippy warnings
  • Loading branch information
reaperhulk authored Jul 29, 2023
1 parent 7431db7 commit 0da7165
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/rust/src/asn1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ struct TestCertificate {
subject_value_tags: Vec<u8>,
}

fn parse_name_value_tags(rdns: &mut Name<'_>) -> Vec<u8> {
fn parse_name_value_tags(rdns: &Name<'_>) -> Vec<u8> {
let mut tags = vec![];
for rdn in rdns.unwrap_read().clone() {
let mut attributes = rdn.collect::<Vec<_>>();
Expand All @@ -168,13 +168,13 @@ fn time_tag(t: &Time) -> u8 {

#[pyo3::prelude::pyfunction]
fn test_parse_certificate(data: &[u8]) -> Result<TestCertificate, CryptographyError> {
let mut cert = asn1::parse_single::<Certificate<'_>>(data)?;
let cert = asn1::parse_single::<Certificate<'_>>(data)?;

Ok(TestCertificate {
not_before_tag: time_tag(&cert.tbs_cert.validity.not_before),
not_after_tag: time_tag(&cert.tbs_cert.validity.not_after),
issuer_value_tags: parse_name_value_tags(&mut cert.tbs_cert.issuer),
subject_value_tags: parse_name_value_tags(&mut cert.tbs_cert.subject),
issuer_value_tags: parse_name_value_tags(&cert.tbs_cert.issuer),
subject_value_tags: parse_name_value_tags(&cert.tbs_cert.subject),
})
}

Expand Down
5 changes: 5 additions & 0 deletions src/rust/src/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ impl FixedPool {
})
}
}

fn __traverse__(&self, visit: pyo3::PyVisit<'_>) -> Result<(), pyo3::PyTraverseError> {
visit.call(&self.create_fn)?;
Ok(())
}
}

#[pyo3::pymethods]
Expand Down

0 comments on commit 0da7165

Please sign in to comment.