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 | 7cc8f7e86db492cd8bed5413fa6952a3b4677d2d (patch) | |
tree | 4d266172ebd2dbccc599c86e8ad602c3e4da0c8d /llvm/lib/VMCore/Value.cpp | |
parent | ca414c7cae143464da9f7051dd8b28c28b2baed7 (diff) | |
download | bcm5719-llvm-7cc8f7e86db492cd8bed5413fa6952a3b4677d2d.tar.gz bcm5719-llvm-7cc8f7e86db492cd8bed5413fa6952a3b4677d2d.zip |
Make sure getName().data() is always null terminated.
llvm-svn: 77149
Diffstat (limited to 'llvm/lib/VMCore/Value.cpp')
-rw-r--r-- | llvm/lib/VMCore/Value.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/VMCore/Value.cpp b/llvm/lib/VMCore/Value.cpp index fa82bac60e3..10e62ff1bc3 100644 --- a/llvm/lib/VMCore/Value.cpp +++ b/llvm/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(); } |