From 06e470d8fc0ae0e83fe0977fdf8c011998980891 Mon Sep 17 00:00:00 2001 From: Patrick Monnerat Date: Sat, 29 Nov 2025 15:48:55 +0100 Subject: [PATCH] gdb: handle unlimited screen width case in print_gdb_hints This avoids a crash when this function is called while screen width is unlimited. In such a case (unconditionally occurring in insight), WIDTH is returned as a negative signed integer, so it has to be compared to another signed integer, not a size_t. Also remove an unused WIDTH-sized variable that may fail in the above case. --- gdb/top.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/gdb/top.c b/gdb/top.c index 0798fea7a3b..52ec66b0607 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -1439,12 +1439,11 @@ print_gdb_hints (struct ui_file *stream) styled_string (command_style.style (), "apropos ")); /* If there isn't enough space to display the longest URL in a boxed - style, use the simple styling of a singular visual break. The longest - URL is used because the other messages may be broken into multiple - lines, but URLs can't. */ - if (width - 3 <= docs_url.length ()) + style or if screen width is unlimited, use the simple styling of a + singular visual break. The longest URL is used because the other + messages may be broken into multiple lines, but URLs can't. */ + if (width - 3 <= (int) docs_url.length ()) { - std::string sep (width, '-'); for (string_file &msg : styled_msg) gdb_printf (stream, "%s\n", msg.c_str ()); -- 2.47.3