Make sure getName().data() is always null terminated.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77149 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar 2009-07-26 09:22:02 +00:00
parent f0443c1eb4
commit 4fa4990bdc

View File

@ -152,7 +152,10 @@ static bool getSymTab(Value *V, ValueSymbolTable *&ST) {
}
StringRef Value::getName() const {
if (!Name) return StringRef();
// Make sure the empty string is still a C string. For historical reasons,
// some clients want to call .data() on the result and expect it to be null
// terminated.
if (!Name) return StringRef("", 0);
return Name->getKey();
}