Skip to content

Commit

Permalink
Fix use-after-free found by ASAN
Browse files Browse the repository at this point in the history
DenseMap::lookup returns copy of the value in the map. Returning the
address of the temporary return value will cause use-after-free.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295675 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
cachemeifyoucan committed Feb 20, 2017
1 parent cce48e3 commit acfd73b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/llvm/Support/DebugCounter.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class DebugCounter {
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));
}

Expand Down

0 comments on commit acfd73b

Please sign in to comment.