[PATCH] D53509: Fix llvm-strings crash for negative char values

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 24 06:18:29 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL345137: Fix llvm-strings crash for negative char values (authored by jhenderson, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53509?vs=170620&id=170864#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53509

Files:
  llvm/trunk/test/tools/llvm-strings/negative-char.test
  llvm/trunk/tools/llvm-strings/llvm-strings.cpp


Index: llvm/trunk/tools/llvm-strings/llvm-strings.cpp
===================================================================
--- llvm/trunk/tools/llvm-strings/llvm-strings.cpp
+++ llvm/trunk/tools/llvm-strings/llvm-strings.cpp
@@ -80,7 +80,7 @@
   const char *B = Contents.begin();
   const char *P = nullptr, *E = nullptr, *S = nullptr;
   for (P = Contents.begin(), E = Contents.end(); P < E; ++P) {
-    if (std::isgraph(*P) || std::isblank(*P)) {
+    if (isPrint(*P) || *P == '\t') {
       if (S == nullptr)
         S = P;
     } else if (S) {
Index: llvm/trunk/test/tools/llvm-strings/negative-char.test
===================================================================
--- llvm/trunk/test/tools/llvm-strings/negative-char.test
+++ llvm/trunk/test/tools/llvm-strings/negative-char.test
@@ -0,0 +1,3 @@
+# RUN: echo -e "z\0\x80\0a\0" | llvm-strings --bytes 1 - | FileCheck %s
+# CHECK: z{{$}}
+# CHECK-NEXT: {{^}} a


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53509.170864.patch
Type: text/x-patch
Size: 922 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181024/51e44894/attachment.bin>


More information about the llvm-commits mailing list