Author: rkovacs Date: Thu Jul 19 10:43:09 2018 New Revision: 337474 URL: http://llvm.org/viewvc/llvm-project?rev=337474&view=rev Log: [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. Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp?rev=337474&r1=337473&r2=337474&view=diff ============================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp Thu Jul 19 10:43:09 2018 @@ -2899,7 +2899,7 @@ std::shared_ptr<PathDiagnosticPiece> Mal // (__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> Mal } OS << "'"; } - Msg = OS.str().data(); + Msg = OS.str(); break; } case AF_None: @@ -3004,7 +3004,7 @@ std::shared_ptr<PathDiagnosticPiece> Mal } } - if (!Msg) + if (Msg.empty()) return nullptr; assert(StackHint); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits