diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-07-26 09:22:02 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-07-26 09:22:02 +0000 |
commit | 400bc6d0b5c364cd7142f4da0fedfc86dbb0f6c8 (patch) | |
tree | aeb5494e216a5f76c936d4edcb047609379c25be /lib/VMCore/Value.cpp | |
parent | 0653dc6fadc3b459dd15e6a47a43f5b410130b14 (diff) | |
download | external_llvm-400bc6d0b5c364cd7142f4da0fedfc86dbb0f6c8.zip external_llvm-400bc6d0b5c364cd7142f4da0fedfc86dbb0f6c8.tar.gz external_llvm-400bc6d0b5c364cd7142f4da0fedfc86dbb0f6c8.tar.bz2 |
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
Diffstat (limited to 'lib/VMCore/Value.cpp')
-rw-r--r-- | lib/VMCore/Value.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/VMCore/Value.cpp b/lib/VMCore/Value.cpp index fa82bac..10e62ff 100644 --- a/lib/VMCore/Value.cpp +++ b/lib/VMCore/Value.cpp @@ -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(); } |