Skip to content

Commit 4c12cd1

Browse files
committed
ensure proplist IntoIterator impl is only used with owned instances
it output's an instance with a static lifetime, which we would not want to do with a borrowed proplist instance. luckily the only possible free-standing proplist instances are owned ones created via the `new()` functions. all borrowed instances are only accessible via a reference and thus cannot be used with `into_iter()` which comsumes the input.
1 parent 0edce0d commit 4c12cd1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pulse-binding/src/proplist.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,10 @@ impl IntoIterator for Proplist {
198198
type IntoIter = Iterator<'static>;
199199

200200
fn into_iter(mut self) -> Self::IntoIter {
201+
assert_eq!(false, self.0.weak);
201202
let mut iter = Iterator::new(self.0.ptr);
202-
// Move responsibility for destruction, if it has it (is not weak itself)
203-
iter.pl_ref.weak = self.0.weak;
203+
// Move responsibility for destruction
204+
iter.pl_ref.weak = false;
204205
self.0.weak = true;
205206
iter
206207
}

0 commit comments

Comments
 (0)