]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/debuginfod-support.c
gdb/debuginfod: Prevent out_of_range exception
[thirdparty/binutils-gdb.git] / gdb / debuginfod-support.c
index 6c2d3fb29519feb720a5c54823a7d2a2cca2764d..4ce2e786b6a1b75890b16f5155658ab8ee66e894 100644 (file)
@@ -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 (),