forked from OSchip/llvm-project
[Support/StringSet] Fix memory leak when inserted key already exists.
llvm-svn: 166517
This commit is contained in:
parent
275e8834c1
commit
8e95113597
|
@ -29,8 +29,13 @@ namespace llvm {
|
||||||
assert(!InLang.empty());
|
assert(!InLang.empty());
|
||||||
const char *KeyStart = InLang.data();
|
const char *KeyStart = InLang.data();
|
||||||
const char *KeyEnd = KeyStart + InLang.size();
|
const char *KeyEnd = KeyStart + InLang.size();
|
||||||
return base::insert(llvm::StringMapEntry<char>::
|
llvm::StringMapEntry<char> *Entry = llvm::StringMapEntry<char>::
|
||||||
Create(KeyStart, KeyEnd, base::getAllocator(), '+'));
|
Create(KeyStart, KeyEnd, base::getAllocator(), '+');
|
||||||
|
if (!base::insert(Entry)) {
|
||||||
|
Entry->Destroy(base::getAllocator());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue