From fd67095cff7f96b4a82ee157e09e3b3792cee680 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Mon, 2 Mar 2026 04:12:50 +0900 Subject: [PATCH] Fix panic in BuiltinPager drop when pager thread panics The Drop impl for OutputType::BuiltinPager calls handle.take().unwrap().join().unwrap() which panics if the pager thread itself panicked. In Drop, this causes a double panic (abort). Replace with if-let and discard the join result, matching the pattern used for OutputType::Pager which also uses let _ =. Reported in #3449 where BAT_PAGER=builtin with --help causes the pager thread to fail. Fixes #3449 --- src/output.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/output.rs b/src/output.rs index fbae5483..0205f48e 100644 --- a/src/output.rs +++ b/src/output.rs @@ -225,8 +225,8 @@ impl Drop for OutputType { let _ = command.wait(); } OutputType::BuiltinPager(ref mut pager) => { - if pager.handle.is_some() { - let _ = pager.handle.take().unwrap().join().unwrap(); + if let Some(handle) = pager.handle.take() { + let _ = handle.join(); } } OutputType::Stdout(_) => (),