diff options
| author | Reka Kovacs <rekanikolett@gmail.com> | 2018-07-19 17:43:09 +0000 | 
|---|---|---|
| committer | Reka Kovacs <rekanikolett@gmail.com> | 2018-07-19 17:43:09 +0000 | 
| commit | a14a2fed3876cb88fd160884064723d47814c744 (patch) | |
| tree | 256db3d6fda62d5a6cd6248ceca7f6d6ac134e05 /clang/lib/StaticAnalyzer/Checkers | |
| parent | e69755a55f43111469880f2d77f4c1548f7bed39 (diff) | |
| download | bcm5719-llvm-a14a2fed3876cb88fd160884064723d47814c744.tar.gz bcm5719-llvm-a14a2fed3876cb88fd160884064723d47814c744.zip  | |
[analyzer] Fix memory sanitizer error in MallocChecker.
StringRef's data() returns a string that may be non-null-terminated.
Switch to using StringRefs from const char pointers in visitor notes
to avoid problems.
llvm-svn: 337474
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers')
| -rw-r--r-- | clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp | 6 | 
1 files changed, 3 insertions, 3 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp index 5dcd9b3863a..be3289a3950 100644 --- a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -2899,7 +2899,7 @@ std::shared_ptr<PathDiagnosticPiece> MallocChecker::MallocBugVisitor::VisitNode(    // (__attribute__((cleanup))).    // Find out if this is an interesting point and what is the kind. -  const char *Msg = nullptr; +  StringRef Msg;    StackHintGeneratorForSymbol *StackHint = nullptr;    SmallString<256> Buf;    llvm::raw_svector_ostream OS(Buf); @@ -2933,7 +2933,7 @@ std::shared_ptr<PathDiagnosticPiece> MallocChecker::MallocBugVisitor::VisitNode(              }              OS << "'";            } -          Msg = OS.str().data(); +          Msg = OS.str();            break;          }          case AF_None: @@ -3004,7 +3004,7 @@ std::shared_ptr<PathDiagnosticPiece> MallocChecker::MallocBugVisitor::VisitNode(      }    } -  if (!Msg) +  if (Msg.empty())      return nullptr;    assert(StackHint);  | 

