From: Simon Marchi <simon.marchi@polymtl.ca>
To: Aaron Merey <amerey@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb/debuginfod: Prevent out_of_range exception
Date: Sat, 9 Apr 2022 11:41:47 -0400 [thread overview]
Message-ID: <acb3039a-683b-8a3e-cca4-f12a765ea67b@polymtl.ca> (raw)
In-Reply-To: <20220408225056.55592-1-amerey@redhat.com>
On 2022-04-08 18:50, Aaron Merey via Gdb-patches wrote:
> 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;
The change LGTM. A test would be nice though, if not too complicated.
Also, I wonder if that url_view.empty() check is useful though. Can it
really happen?
Simon
next prev parent reply other threads:[~2022-04-09 15:41 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-08 22:50 Aaron Merey
2022-04-09 15:41 ` Simon Marchi [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=acb3039a-683b-8a3e-cca4-f12a765ea67b@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=amerey@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).