From: Patrick Donnelly Date: Thu, 14 Nov 2024 18:33:11 +0000 (-0500) Subject: include/filepath: add empty path check X-Git-Tag: v20.0.0^2~58 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=e62fce4ec98ab03d9e71bd6e49bf2d8568a8fe71;p=ceph.git include/filepath: add empty path check When passing an empty string to filepath, it would test if the first character is '/' which is an invalid access through std::string_view. Signed-off-by: Patrick Donnelly Fixes: https://tracker.ceph.com/issues/66373 --- diff --git a/src/include/filepath.h b/src/include/filepath.h index 0d2358128cfaf..9379cb583280f 100644 --- a/src/include/filepath.h +++ b/src/include/filepath.h @@ -98,7 +98,7 @@ class filepath { ino = b; } void set_path(std::string_view s) { - if (s[0] == '/') { + if (!s.empty() && s[0] == '/') { path = s.substr(1); ino = 1; } else {