Skip to content

Commit

Permalink
Fix realloc_buffer function
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeySotkin committed Jan 25, 2019
1 parent d936479 commit 6257ffe
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pch_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,12 @@ const char* ResourceManager::realloc_buffer(const char *id,
size_t alloc_size = requireNullTerminate ? size + 1 : size;
buffer.resize(alloc_size);
buffer.assign(buf, buf + size);
buffer.back() = '\0';
// The data in the buffer will be eventually passed to llvm::MemoryBufferMem
// ctor via argument of StringRef type. The Length of this StringRef will be
// = the 'size' argument of this function. There is an assert in
// llvm::MemoryBuffer::init checking that element *past the end* of the memory
// range passed via the ctor is '\0'. So we add it here.
buffer.push_back('\0');

return &buffer[0];
}
Expand Down

0 comments on commit 6257ffe

Please sign in to comment.