[llvm] r295675 - Fix use-after-free found by ASAN

Steven Wu via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 20 10:33:40 PST 2017


Author: steven_wu
Date: Mon Feb 20 12:33:40 2017
New Revision: 295675

URL: http://llvm.org/viewvc/llvm-project?rev=295675&view=rev
Log:
Fix use-after-free found by ASAN

DenseMap::lookup returns copy of the value in the map. Returning the
address of the temporary return value will cause use-after-free.

Modified:
    llvm/trunk/include/llvm/Support/DebugCounter.h

Modified: llvm/trunk/include/llvm/Support/DebugCounter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/DebugCounter.h?rev=295675&r1=295674&r2=295675&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/DebugCounter.h (original)
+++ llvm/trunk/include/llvm/Support/DebugCounter.h Mon Feb 20 12:33:40 2017
@@ -111,7 +111,7 @@ public:
   unsigned int getNumCounters() const { return RegisteredCounters.size(); }
 
   // Return the name and description of the counter with the given ID.
-  std::pair<StringRef, StringRef> getCounterInfo(unsigned ID) const {
+  std::pair<std::string, std::string> getCounterInfo(unsigned ID) const {
     return std::make_pair(RegisteredCounters[ID], CounterDesc.lookup(ID));
   }
 




More information about the llvm-commits mailing list