diff options
author | Aaron Merey <amerey@redhat.com> | 2022-04-08 18:50:56 -0400 |
---|---|---|
committer | Aaron Merey <amerey@redhat.com> | 2022-04-20 17:40:05 -0400 |
commit | 52449404c4e38000351e8f2c7b768f12fd808eda (patch) | |
tree | d26145c93b7c7c15fe93fbc394ccfbc11cec5897 /gdb/debuginfod-support.c | |
parent | b750766ac9652def5307925b8fc5c215fbcef8df (diff) | |
download | gdb-52449404c4e38000351e8f2c7b768f12fd808eda.zip gdb-52449404c4e38000351e8f2c7b768f12fd808eda.tar.gz gdb-52449404c4e38000351e8f2c7b768f12fd808eda.tar.bz2 |
gdb/debuginfod: Prevent out_of_range exception
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.
Also add first use notice testcases.
Co-Authored-By: Pedro Alves <pedro@palves.net>
Diffstat (limited to 'gdb/debuginfod-support.c')
-rw-r--r-- | gdb/debuginfod-support.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c index 6c2d3fb..4ce2e78 100644 --- a/gdb/debuginfod-support.c +++ b/gdb/debuginfod-support.c @@ -187,10 +187,11 @@ debuginfod_is_enabled () gdb::string_view url_view (urls); while (true) { - url_view = url_view.substr (url_view.find_first_not_of (' ')); - if (url_view.empty ()) + size_t off = url_view.find_first_not_of (' '); + if (off == gdb::string_view::npos) break; - size_t off = url_view.find_first_of (' '); + url_view = url_view.substr (off); + off = url_view.find_first_of (' '); gdb_printf (_(" <%ps>\n"), styled_string (file_name_style.style (), |