Skip to content

Commit c00c442

Browse files
committed
Bugfix: don't leak on WithOrigin (or WithRawSiginfo) destruction
1 parent c360cc8 commit c00c442

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Folding the signal-hook-sys inline (but still compiling C code only
66
conditionally).
77
* `WithRawSiginfo` extractor (to get hands on the raw `siginfo_t`).
8+
* Bugfix: Don't leak on WithOrigin destruction.
89

910
# 0.3.1
1011

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ maintenance = { status = "actively-developed" }
2020
channel = []
2121
default = ["channel", "iterator"]
2222
iterator = []
23+
# TODO: Unify them on the next breaking release.
2324
extended-siginfo = ["channel", "iterator", "extended-siginfo-raw"]
2425
extended-siginfo-raw = ["cc"]
2526

src/iterator/exfiltrator/raw.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ use crate::low_level::channel::Channel;
2020
#[derive(Default, Debug)]
2121
pub struct Slot(AtomicPtr<Channel<siginfo_t>>);
2222

23+
impl Drop for Slot {
24+
fn drop(&mut self) {
25+
let ptr = self.0.load(Ordering::Acquire);
26+
if !ptr.is_null() {
27+
drop(unsafe { Box::from_raw(ptr) });
28+
}
29+
}
30+
}
31+
2332
/// The [`Exfiltrator`][crate::iterator::exfiltrator::Exfiltrator] that produces the raw
2433
/// [`libc::siginfo_t`]. Note that it might look differently on different OSes and its API is a
2534
/// little bit more limited than its C counterpart.

0 commit comments

Comments
 (0)