object_path: fix potential buffer overrun
The `filename` function attempted to look at the first character
of a substring, which could have been empty. This was noticed by
UBSAN in GCC 13.2.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I7397861b6b19ef86d1c5c01dc1007a8804d08ab6
diff --git a/src/message/native_types.cpp b/src/message/native_types.cpp
index bdb9354..16f7b48 100644
--- a/src/message/native_types.cpp
+++ b/src/message/native_types.cpp
@@ -64,7 +64,7 @@
// If we don't see that this was encoded by sdbusplus, return the naive
// version of the filename path.
- if (filename[0] != '_')
+ if (filename.empty() || filename[0] != '_')
{
return std::string(filename);
}