]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: handle unlimited screen width case in print_gdb_hints
authorPatrick Monnerat <patrick@monnerat.net>
Sat, 29 Nov 2025 14:48:55 +0000 (15:48 +0100)
committerPatrick Monnerat <patrick@monnerat.net>
Thu, 4 Dec 2025 13:22:00 +0000 (14:22 +0100)
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

index 0798fea7a3bbfbbea6ac192c6ca9a15ebeb30d0e..52ec66b060772b7b68c4055fb747645d3fd83ad0 100644 (file)
--- 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 <word>"));
 
   /* 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 ());