[compiler-rt] 5019b0a - [scudo] Fix String DCHECK

Kostya Kortchinsky via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 4 13:42:11 PDT 2021


Author: Kostya Kortchinsky
Date: 2021-06-04T13:41:59-07:00
New Revision: 5019b0a56588fc13e6a37c49e22a812afe6c4416

URL: https://github.com/llvm/llvm-project/commit/5019b0a56588fc13e6a37c49e22a812afe6c4416
DIFF: https://github.com/llvm/llvm-project/commit/5019b0a56588fc13e6a37c49e22a812afe6c4416.diff

LOG: [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

Added: 
    

Modified: 
    compiler-rt/lib/scudo/standalone/string_utils.h

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/scudo/standalone/string_utils.h b/compiler-rt/lib/scudo/standalone/string_utils.h
index 7a57da3a53f4..7c1cd5753068 100644
--- a/compiler-rt/lib/scudo/standalone/string_utils.h
+++ b/compiler-rt/lib/scudo/standalone/string_utils.h
@@ -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);


        


More information about the llvm-commits mailing list