From: Patrick Monnerat Date: Sat, 29 Nov 2025 14:48:55 +0000 (+0100) Subject: gdb: handle unlimited screen width case in print_gdb_hints X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=06e470d8fc0ae0e83fe0977fdf8c011998980891;p=thirdparty%2Fbinutils-gdb.git 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. --- 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 ());