]> granicus.if.org Git - clang/commitdiff
[analyzer] Fix a memory error in r261935 caught by the Windows bots.
authorDevin Coughlin <dcoughlin@apple.com>
Fri, 26 Feb 2016 00:23:41 +0000 (00:23 +0000)
committerDevin Coughlin <dcoughlin@apple.com>
Fri, 26 Feb 2016 00:23:41 +0000 (00:23 +0000)
It was using a temporary StringRef after its underlying storage was freed.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@261944 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp

index 596ad70c423e43dc9e33073912441b42b96c0477..263da2014656db74cbd6ed98540fef3cb96fbcb1 100644 (file)
@@ -162,9 +162,9 @@ void ObjCSuperDeallocChecker::checkLocation(SVal L, bool IsLoad, const Stmt *S,
   StringRef Desc = StringRef();
   auto *IvarRegion = dyn_cast_or_null<ObjCIvarRegion>(PriorSubRegion);
 
+  std::string Buf;
+  llvm::raw_string_ostream OS(Buf);
   if (IvarRegion) {
-    std::string Buf;
-    llvm::raw_string_ostream OS(Buf);
     OS << "use of instance variable '" << *IvarRegion->getDecl() <<
           "' after the instance has been freed with call to [super dealloc]";
     Desc = OS.str();