Skip to content

Commit e61aa98

Browse files
authored
Merge pull request #402 from shinmili/fix-double-panic
Avoid potential double panicking in tests
2 parents 7aeb1ba + f2d8a68 commit e61aa98

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

plotters/src/drawing/backend_impl/mocked.rs

+7
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,13 @@ impl DrawingBackend for MockedBackend {
269269

270270
impl Drop for MockedBackend {
271271
fn drop(&mut self) {
272+
// `self.drop_check` is typically a testing function; it can panic.
273+
// The current `drop` call may be a part of stack unwinding caused
274+
// by another panic. If so, we should never call it.
275+
if std::thread::panicking() {
276+
return;
277+
}
278+
272279
let mut temp = None;
273280
std::mem::swap(&mut temp, &mut self.drop_check);
274281

0 commit comments

Comments
 (0)