[Lldb-commits] [lldb] 1d1d916 - Fix an embarrasing use-after-free from a895a446bcde
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Fri Oct 30 08:54:35 PDT 2020
Author: Pavel Labath
Date: 2020-10-30T16:54:24+01:00
New Revision: 1d1d916f960e1ab059d4223abf91bea91780a7e9
URL: https://github.com/llvm/llvm-project/commit/1d1d916f960e1ab059d4223abf91bea91780a7e9
DIFF: https://github.com/llvm/llvm-project/commit/1d1d916f960e1ab059d4223abf91bea91780a7e9.diff
LOG: Fix an embarrasing use-after-free from a895a446bcde
Added:
Modified:
lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.cpp
lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.h
lldb/unittests/TestingSupport/TestUtilities.h
Removed:
################################################################################
diff --git a/lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.cpp b/lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.cpp
index 6549ec9f0f54..15db62451f91 100644
--- a/lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.cpp
+++ b/lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.cpp
@@ -9,7 +9,6 @@
#include "TestingSupport/Symbol/YAMLModuleTester.h"
#include "Plugins/SymbolFile/DWARF/DWARFDebugInfo.h"
#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
-#include "TestingSupport/TestUtilities.h"
#include "lldb/Core/Section.h"
#include "llvm/ObjectYAML/DWARFEmitter.h"
@@ -18,8 +17,9 @@ using namespace lldb_private;
YAMLModuleTester::YAMLModuleTester(llvm::StringRef yaml_data) {
llvm::Expected<TestFile> File = TestFile::fromYaml(yaml_data);
EXPECT_THAT_EXPECTED(File, llvm::Succeeded());
+ m_file = std::move(*File);
- m_module_sp = std::make_shared<Module>(File->moduleSpec());
+ m_module_sp = std::make_shared<Module>(m_file->moduleSpec());
auto &symfile = *llvm::cast<SymbolFileDWARF>(m_module_sp->GetSymbolFile());
m_dwarf_unit = symfile.DebugInfo().GetUnitAtIndex(0);
diff --git a/lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.h b/lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.h
index 69bb392aaaf6..60715ab2c16a 100644
--- a/lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.h
+++ b/lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.h
@@ -14,6 +14,7 @@
#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "TestingSupport/SubsystemRAII.h"
+#include "TestingSupport/TestUtilities.h"
#include "lldb/Core/Module.h"
#include "lldb/Host/HostInfo.h"
@@ -26,6 +27,7 @@ class YAMLModuleTester {
SubsystemRAII<FileSystem, HostInfo, TypeSystemClang, ObjectFileELF,
SymbolFileDWARF>
subsystems;
+ llvm::Optional<TestFile> m_file;
lldb::ModuleSP m_module_sp;
DWARFUnit *m_dwarf_unit;
diff --git a/lldb/unittests/TestingSupport/TestUtilities.h b/lldb/unittests/TestingSupport/TestUtilities.h
index 60a07119e924..811c4c152126 100644
--- a/lldb/unittests/TestingSupport/TestUtilities.h
+++ b/lldb/unittests/TestingSupport/TestUtilities.h
@@ -36,8 +36,6 @@ class TestFile {
static llvm::Expected<TestFile> fromYaml(llvm::StringRef Yaml);
static llvm::Expected<TestFile> fromYamlFile(const llvm::Twine &Name);
- ~TestFile() = default;
-
ModuleSpec moduleSpec() {
return ModuleSpec(FileSpec(), UUID(), dataBuffer());
}
@@ -45,8 +43,6 @@ class TestFile {
private:
TestFile(std::string &&Buffer) : Buffer(std::move(Buffer)) {}
- void operator=(const TestFile &) = delete;
-
lldb::DataBufferSP dataBuffer() {
auto *Data = reinterpret_cast<const uint8_t *>(Buffer.data());
return std::make_shared<DataBufferUnowned>(const_cast<uint8_t *>(Data),
More information about the lldb-commits
mailing list