diff options
author | Zachary Turner <zturner@google.com> | 2017-06-03 00:33:35 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2017-06-03 00:33:35 +0000 |
commit | 5b74ff33e7a31c2939e978e1c5541883fb9cb25f (patch) | |
tree | e5757c6c0f7664a33e51bca87ca296578ec103bb /llvm/lib/DebugInfo/PDB/Native/InfoStreamBuilder.cpp | |
parent | 4e8624d13825326a6e473d986197b5d9007b1153 (diff) | |
download | bcm5719-llvm-5b74ff33e7a31c2939e978e1c5541883fb9cb25f.tar.gz bcm5719-llvm-5b74ff33e7a31c2939e978e1c5541883fb9cb25f.zip |
[PDB] Fix use after free.
Previously MappedBlockStream owned its own BumpPtrAllocator that
it would allocate from when a read crossed a block boundary. This
way it could still return the user a contiguous buffer of the
requested size. However, It's not uncommon to open a stream, read
some stuff, close it, and then save the information for later.
After all, since the entire file is mapped into memory, the data
should always be available as long as the file is open.
Of course, the exception to this is when the data isn't *in* the
file, but rather in some buffer that we temporarily allocated to
present this contiguous view. And this buffer would get destroyed
as soon as the strema was closed.
The fix here is to force the user to specify the allocator, this
way it can provide an allocator that has whatever lifetime it
chooses.
Differential Revision: https://reviews.llvm.org/D33858
llvm-svn: 304623
Diffstat (limited to 'llvm/lib/DebugInfo/PDB/Native/InfoStreamBuilder.cpp')
-rw-r--r-- | llvm/lib/DebugInfo/PDB/Native/InfoStreamBuilder.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Native/InfoStreamBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/InfoStreamBuilder.cpp index f019d410328..707128f7efd 100644 --- a/llvm/lib/DebugInfo/PDB/Native/InfoStreamBuilder.cpp +++ b/llvm/lib/DebugInfo/PDB/Native/InfoStreamBuilder.cpp @@ -50,8 +50,8 @@ Error InfoStreamBuilder::finalizeMsfLayout() { Error InfoStreamBuilder::commit(const msf::MSFLayout &Layout, WritableBinaryStreamRef Buffer) const { - auto InfoS = - WritableMappedBlockStream::createIndexedStream(Layout, Buffer, StreamPDB); + auto InfoS = WritableMappedBlockStream::createIndexedStream( + Layout, Buffer, StreamPDB, Msf.getAllocator()); BinaryStreamWriter Writer(*InfoS); InfoStreamHeader H; |