Avoid potential index-out-of-bounds

This commit is contained in:
Andrew Noyes 2019-04-15 15:20:09 -07:00
parent 77843e8494
commit 6c7fd1593f
2 changed files with 2 additions and 1 deletions

View File

@ -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
}

View File

@ -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;
}