diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-11-19 21:12:39 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-11-19 21:12:39 +0000 |
commit | edeaa6454ef1dc29fa3144b93e2121495b160b35 (patch) | |
tree | beb9ac26a0bd4914e84b584d2466c6923cf60851 /lib | |
parent | a49e1f55da902fe1b50e3ea989357d3e70b24dc9 (diff) | |
download | llvm-edeaa6454ef1dc29fa3144b93e2121495b160b35.tar.gz llvm-edeaa6454ef1dc29fa3144b93e2121495b160b35.tar.bz2 llvm-edeaa6454ef1dc29fa3144b93e2121495b160b35.tar.xz |
Make it explicit that nulls are not allowed in names.
The object files we support use null terminated strings, so there is no way to
support these.
This patch adds an assert to catch bad API use and an error check in the .ll
parser.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195155 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AsmParser/LLLexer.cpp | 4 | ||||
-rw-r--r-- | lib/IR/Value.cpp | 2 |
2 files changed, 6 insertions, 0 deletions
diff --git a/lib/AsmParser/LLLexer.cpp b/lib/AsmParser/LLLexer.cpp index 1e6085b443..3c384f5fcc 100644 --- a/lib/AsmParser/LLLexer.cpp +++ b/lib/AsmParser/LLLexer.cpp @@ -275,6 +275,10 @@ lltok::Kind LLLexer::LexAt() { if (CurChar == '"') { StrVal.assign(TokStart+2, CurPtr-1); UnEscapeLexed(StrVal); + if (StringRef(StrVal).find_first_of(0) != StringRef::npos) { + Error("Null bytes are not allowed in names"); + return lltok::Error; + } return lltok::GlobalVar; } } diff --git a/lib/IR/Value.cpp b/lib/IR/Value.cpp index 62a3b31c18..2c90383edd 100644 --- a/lib/IR/Value.cpp +++ b/lib/IR/Value.cpp @@ -182,6 +182,8 @@ void Value::setName(const Twine &NewName) { SmallString<256> NameData; StringRef NameRef = NewName.toStringRef(NameData); + assert(NameRef.find_first_of(0) == StringRef::npos && + "Null bytes are not allowed in names"); // Name isn't changing? if (getName() == NameRef) |