public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb/debuginfod: Prevent out_of_range exception
@ 2022-04-08 22:50 Aaron Merey
  2022-04-09 15:41 ` Simon Marchi
  2022-04-12 16:09 ` [PATCH] gdb/debuginfod: Prevent out_of_range exception Tom Tromey
  0 siblings, 2 replies; 12+ messages in thread
From: Aaron Merey @ 2022-04-08 22:50 UTC (permalink / raw)
  To: gdb-patches

Trailing whitespace in the string of debuginfod URLs causes an
out_of_range exception during the printing of URLs for the first
use notice.

To fix this, stop printing URLs when the substring to be printed
consists only of whitespace.
---
 gdb/debuginfod-support.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
index 6c2d3fb2951..668c50c405c 100644
--- a/gdb/debuginfod-support.c
+++ b/gdb/debuginfod-support.c
@@ -187,10 +187,13 @@ debuginfod_is_enabled ()
       gdb::string_view url_view (urls);
       while (true)
 	{
-	  url_view = url_view.substr (url_view.find_first_not_of (' '));
+	  size_t off = url_view.find_first_not_of (' ');
+	  if (off == gdb::string_view::npos)
+	    break;
+	  url_view = url_view.substr (off);
 	  if (url_view.empty ())
 	    break;
-	  size_t off = url_view.find_first_of (' ');
+	  off = url_view.find_first_of (' ');
 	  gdb_printf
 	    (_("  <%ps>\n"),
 	     styled_string (file_name_style.style (),
-- 
2.35.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-04-21 12:49 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-08 22:50 [PATCH] gdb/debuginfod: Prevent out_of_range exception Aaron Merey
2022-04-09 15:41 ` Simon Marchi
2022-04-14 18:56   ` Aaron Merey
2022-04-18 14:13     ` Tom Tromey
2022-04-18 16:25     ` Pedro Alves
2022-04-19 20:38       ` Aaron Merey
2022-04-19 20:44         ` Pedro Alves
2022-04-19 21:11           ` Aaron Merey
2022-04-20 19:24             ` Pedro Alves
2022-04-20 22:09               ` Aaron Merey
2022-04-21 12:49               ` [pushed] gdb.debuginfod/fetch_src_and_symbols.exp: Fix "notice empty URL" test Pedro Alves
2022-04-12 16:09 ` [PATCH] gdb/debuginfod: Prevent out_of_range exception Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).