[PATCH] D103716: [scudo] Fix String DCHECK

Kostya Kortchinsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 4 13:38:56 PDT 2021


cryptoad created this revision.
cryptoad added reviewers: hctim, vitalybuka, cferris, pcc.
cryptoad requested review of this revision.
Herald added a project: Sanitizers.
Herald added a subscriber: Sanitizers.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103716

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


Index: compiler-rt/lib/scudo/standalone/string_utils.h
===================================================================
--- compiler-rt/lib/scudo/standalone/string_utils.h
+++ compiler-rt/lib/scudo/standalone/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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103716.349959.patch
Type: text/x-patch
Size: 671 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210604/6f160ae1/attachment-0001.bin>


More information about the llvm-commits mailing list