public inbox for yew-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH yew-comp] rrd: fix debug mode panic when graph is too narrow
@ 2026-06-18 11:44 Dominik Csapak
  0 siblings, 0 replies; only message in thread
From: Dominik Csapak @ 2026-06-18 11:44 UTC (permalink / raw)
  To: yew-devel

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





^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-06-18 11:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-18 11:44 [PATCH yew-comp] rrd: fix debug mode panic when graph is too narrow Dominik Csapak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal