Skip to content

Commit

Permalink
Fix potential dobule-borrow panic. (#3807)
Browse files Browse the repository at this point in the history
There is one place in code, where we can potentially panic on double borrow, because the drop routine is done while having data borrowed.

# Important Notes
The issue was easily reproducible on @Frizi machine.
  • Loading branch information
farmaazon authored Oct 19, 2022
1 parent 21fe0b8 commit c4e89a8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/rust/frp/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,10 @@ impl BridgeNetwork {
}

fn destroy(&self) {
*self.data.borrow_mut() = None
self.data.take();
// Beware: doing it in another, also intuitive way
// *self.data.borrow_mut() = None
// May cause a panic, because the drop procedure is done while keeping data borrowed.
}
}

Expand Down

0 comments on commit c4e89a8

Please sign in to comment.