Check RequiresNullTerminator first, or we might read from an invalid address.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127853 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2011-03-18 02:55:51 +00:00
parent b4b8b0cc90
commit 49ab1207df

View File

@ -48,7 +48,7 @@ MemoryBuffer::~MemoryBuffer() { }
/// memory, memory that we know is already null terminated.
void MemoryBuffer::init(const char *BufStart, const char *BufEnd,
bool RequiresNullTerminator) {
assert((BufEnd[0] == 0 || !RequiresNullTerminator) &&
assert((!RequiresNullTerminator || BufEnd[0] == 0) &&
"Buffer is not null terminated!");
BufferStart = BufStart;
BufferEnd = BufEnd;