From 9b44f2eaea136cae30543ecbad96827af7ff579c Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 6 Sep 2023 17:05:17 +0200 Subject: [PATCH] bugfix: Fix length of returned buffer on x11 when using the wire-transferred buffer total_len() computes the number of bytes, while the wire Vec holds u32. --- CHANGELOG.md | 4 ++++ src/x11.rs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb3ff80..0ed55f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# UNRELEASED + +* On X11, fix the length of the returned buffer when using the wire-transferred buffer. + # 0.3.0 * On MacOS, the contents scale is updated when set_buffer() is called, to adapt when the window is on a new screen (#68). diff --git a/src/x11.rs b/src/x11.rs index e8b273c..c9e546f 100644 --- a/src/x11.rs +++ b/src/x11.rs @@ -486,7 +486,7 @@ impl Buffer { match self { Buffer::Shm(ref mut shm) => shm.alloc_segment(conn, total_len(width, height)), Buffer::Wire(wire) => { - wire.resize(total_len(width, height), 0); + wire.resize(total_len(width, height) / 4, 0); Ok(()) } }