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

llvm-svn: 77149
This commit is contained in:
Daniel Dunbar 2009-07-26 09:22:02 +00:00
parent ca414c7cae
commit 7cc8f7e86d
1 changed files with 4 additions and 1 deletions

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();
}