Avoid potential index-out-of-bounds
This commit is contained in:
parent
77843e8494
commit
6c7fd1593f
|
@ -1220,6 +1220,6 @@ void TraceEventFields::validateFormat() const {
|
|||
}
|
||||
|
||||
std::string traceableStringToString(const char* value, size_t S) {
|
||||
ASSERT_WE_THINK(value[S - 1] == '\0');
|
||||
ASSERT_WE_THINK(S > 0 && value[S - 1] == '\0');
|
||||
return std::string(value, S - 1); // Exclude trailing \0 byte
|
||||
}
|
||||
|
|
|
@ -266,6 +266,7 @@ std::string traceableStringToString(const char* value, size_t S);
|
|||
|
||||
template<size_t S>
|
||||
struct TraceableString<char[S]> {
|
||||
static_assert(S > 0, "Only string literals are supported.");
|
||||
static const char* begin(const char* value) {
|
||||
return value;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue