From: Dominik Csapak <d.csapak@proxmox.com>
To: yew-devel@lists.proxmox.com
Subject: [PATCH yew-comp] rrd: fix debug mode panic when graph is too narrow
Date: Thu, 18 Jun 2026 13:44:41 +0200 [thread overview]
Message-ID: <20260618114537.2292990-1-d.csapak@proxmox.com> (raw)
When the graph gets too narrow (e.g. when its width is dynamic and the
viewport is narrow), the subtraction here could overflow, leading to a
panic in debug mode.
getting a negative inner width is not useful anyway, so make the
subtraction saturating.
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
not super problematic as in the release mode this will simply overflow
instead of panic, but i ran into during development, and fixing it
should have no negative impact.
src/rrd/graph_space.rs | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/rrd/graph_space.rs b/src/rrd/graph_space.rs
index cd75177..8728391 100644
--- a/src/rrd/graph_space.rs
+++ b/src/rrd/graph_space.rs
@@ -123,8 +123,12 @@ impl GraphSpace {
fn update_inner_size(&mut self) {
let layout = &mut self.layout;
- layout.inner_width = layout.width - layout.left_offset - layout.grid_border * 2;
- layout.inner_height = layout.height - layout.bottom_offset - layout.grid_border * 2;
+ layout.inner_width = layout
+ .width
+ .saturating_sub(layout.left_offset + layout.grid_border * 2);
+ layout.inner_height = layout
+ .height
+ .saturating_sub(layout.bottom_offset + layout.grid_border * 2);
}
/// Updates the width of the layout, recalculates all necessary fields
--
2.47.3
reply other threads:[~2026-06-18 11:46 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260618114537.2292990-1-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=yew-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.