From da2637af29a5d0c881ac95c2e62947352686d538 Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Tue, 13 Oct 2020 16:25:36 +0300 Subject: [PATCH] Fix crash when failing to write to a clipboard (#29) Fix crash when failing to write to a clipboard --- CHANGELOG.md | 2 ++ src/worker/handlers.rs | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41a433a..7331cdd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- Crash when failing to write to a clipboard + ## 0.6.0 -- 2020-10-03 - Updated smithay-client-toolkit to 0.12 diff --git a/src/worker/handlers.rs b/src/worker/handlers.rs index 08ca172..8e197dd 100644 --- a/src/worker/handlers.rs +++ b/src/worker/handlers.rs @@ -76,7 +76,9 @@ macro_rules! handle_store { vec![MimeType::TextPlainUtf8.to_string(), MimeType::Utf8String.to_string()], move |event, _| { if let $event_ty::Send { mut pipe, .. } = event { - write!(pipe, "{}", $contents).unwrap(); + // If we fail to write here, it means that other side closed the pipe, thus + // we can't do anything about it. + let _ = write!(pipe, "{}", $contents); } }, );