summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2017-05-03 05:34:00 +0000
committerZachary Turner <zturner@google.com>2017-05-03 05:34:00 +0000
commit59e83892e0a029a5d773c8d0a835d471df3ccfd2 (patch)
treeab5a7c8453b62a42f2188ded142d3c0e20342fc6 /llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp
parent79d310713a618b5ba8d2a3ae9cbf58f2dae6899a (diff)
downloadbcm5719-llvm-59e83892e0a029a5d773c8d0a835d471df3ccfd2.tar.gz
bcm5719-llvm-59e83892e0a029a5d773c8d0a835d471df3ccfd2.zip
Fix use after free in BinaryStream library.
This was reported by the ASAN bot, and it turned out to be a fairly fundamental problem with the design of VarStreamArray and the way it passes context information to the extractor. The fix was cumbersome, and I'm not entirely pleased with it, so I plan to revisit this design in the future when I'm not pressed to get the bots green again. For now, this fixes the issue by storing the context information by value instead of by reference, and introduces some impossibly-confusing template magic to make things "work". llvm-svn: 301999
Diffstat (limited to 'llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp')
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp
index f994b4538ef..867864e47dc 100644
--- a/llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp
@@ -89,6 +89,14 @@ uint32_t DbiModuleDescriptorBuilder::calculateSerializedLength() const {
return alignTo(L + M + O, sizeof(uint32_t));
}
+template <typename T> struct Foo {
+ explicit Foo(T &&Answer) : Answer(Answer) {}
+
+ T Answer;
+};
+
+template <typename T> Foo<T> makeFoo(T &&t) { return Foo<T>(std::move(t)); }
+
void DbiModuleDescriptorBuilder::finalize() {
Layout.FileNameOffs = 0; // TODO: Fix this
Layout.Flags = 0; // TODO: Fix this
OpenPOWER on IntegriCloud