[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
GitOrigin-RevId: 5019b0a56588fc13e6a37c49e22a812afe6c4416
diff --git a/string_utils.h b/string_utils.h
index 7a57da3..7c1cd57 100644
--- a/string_utils.h
+++ b/string_utils.h
@@ -18,14 +18,12 @@
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);