diff --git a/src/cxx.cc b/src/cxx.cc index 4958eb08b..d449429da 100644 --- a/src/cxx.cc +++ b/src/cxx.cc @@ -449,8 +449,9 @@ static_assert(!std::is_same::const_iterator, "Vec::const_iterator != Vec::iterator"); static const char *errorCopy(const char *ptr, std::size_t len) { - char *copy = new char[len]; + char *copy = new char[len + 1]; std::memcpy(copy, ptr, len); + copy[len] = 0; return copy; }