[ghex] gtkhex: clamp offset strlen calculation at 0



commit bbad0649e4e082a4fb055b187b561801f7b64bbc
Author: Logan Rathbone <poprocks gmail com>
Date:   Tue Dec 21 18:49:16 2021 -0500

    gtkhex: clamp offset strlen calculation at 0

 src/gtkhex.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/src/gtkhex.c b/src/gtkhex.c
index 42f357c..73c74c2 100644
--- a/src/gtkhex.c
+++ b/src/gtkhex.c
@@ -1094,7 +1094,8 @@ render_offsets (GtkHex *gh,
        /* find out how many chars wide our offset column should be based on
         * how many chars will be in the last offset marker of the screen */
        
-       snprintf (buf, BUFLEN-1, "%lX", (gh->top_line + max_lines - 1) * gh->cpl);
+       snprintf (buf, BUFLEN-1, "%lX",
+                       MAX ((gh->top_line + max_lines - 1), 0) * gh->cpl);
        off_cpl = MAX (MIN_CPL, strlen (buf));
        snprintf (fmt, BUFLEN-1, "%%0%dlX", off_cpl); 
        gtk_hex_layout_set_offset_cpl (GTK_HEX_LAYOUT(gh->layout_manager), off_cpl);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]