[scudo] Fix String DCHECK

This resolves an issue tripping a `DCHECK`, as I was checking for the
capacity and not the size. We don't need to 0-init the Vector as it's
done already, and make sure we only 0-out the string on clear if it's
not empty.

Differential Revision: https://reviews.llvm.org/D103716
This commit is contained in:
Kostya Kortchinsky 2021-06-04 13:38:26 -07:00
parent efea1b1782
commit 5019b0a565
1 changed files with 3 additions and 5 deletions

View File

@ -18,14 +18,12 @@ namespace scudo {
class ScopedString {
public:
explicit ScopedString() : String() {
if (String.capacity() > 0)
String[0] = '\0';
}
explicit ScopedString() : String() {}
uptr length() { return Length; }
const char *data() { return String.data(); }
void clear() {
String[0] = '\0';
if (!String.empty())
String[0] = '\0';
Length = 0;
}
void append(const char *Format, va_list Args);