From 26ecf7c4a5680431c4bc3b5a260ba2df3a5ca6a2 Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Thu, 14 Nov 2024 13:33:11 -0500 Subject: [PATCH] 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 (cherry picked from commit e62fce4ec98ab03d9e71bd6e49bf2d8568a8fe71) --- src/include/filepath.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/filepath.h b/src/include/filepath.h index d0965ad0cf954..dcdfe76e7974b 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 { -- 2.39.5