Displaying 2 results from an estimated 2 matches for "memorybuffermmapfile".
2016 Nov 17
3
UB in MemoryBufferMMapFile
...bool RequiresNullTerminator) {
> assert((!RequiresNullTerminator || BufEnd[0] == 0) &&
> "Buffer is not null terminated!");
> BufferStart = BufStart;
> BufferEnd = BufEnd;
> }
However, this can be, and often is, one past an allocated region, since
in MemoryBufferMMapFile we mmap `Len` bytes and then call this with
`BufEnd = Start + Len`:
from lib/Support/MemoryBuffer.cpp:210:
> MemoryBufferMMapFile(bool RequiresNullTerminator, int FD, uint64_t Len,
> uint64_t Offset, std::error_code &EC)
> : MFR(FD, sys::fs::mapped_file_...
2016 Nov 17
2
UB in MemoryBufferMMapFile
...behavior free. In the case where you’re not mmaping a
> file (e.g. for clang, if the file is small) it is easy enough to
> malloc one byte more than you need to ensure the zero byte is present.
>
>> However, this can be, and often is, one past an allocated region, since
>> in MemoryBufferMMapFile we mmap `Len` bytes and then call this with
>> `BufEnd = Start + Len`:
>>
>> from lib/Support/MemoryBuffer.cpp:210:
>>> MemoryBufferMMapFile(bool RequiresNullTerminator, int FD, uint64_t Len,
>>> uint64_t Offset, std::error_code &EC)
&...