diff options
author | Adrian Prantl <aprantl@apple.com> | 2023-04-21 08:20:39 -0700 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2023-04-21 08:21:56 -0700 |
commit | 737820e6d6e2df50f2ddf522a0db9ffb794ff749 (patch) | |
tree | 12d8214f34f3d4c8e2db80f58d0dc821619a0672 /lldb/unittests | |
parent | 6c9066fe2ecc3fa04d857db864ee9a4d08b30740 (diff) | |
download | llvm-737820e6d6e2df50f2ddf522a0db9ffb794ff749.tar.gz |
Make diagnostics API safer to use
I received a crash report in DiagnosticManager that was caused by a
nullptr diagnostic having been added. The API allows passing in a null
unique_ptr, but all the methods are written assuming that all pointers
a dereferencable. This patch makes it impossible to add a null
diagnostic.
rdar://107633615
Differential Revision: https://reviews.llvm.org/D148823
Diffstat (limited to 'lldb/unittests')
-rw-r--r-- | lldb/unittests/Expression/DiagnosticManagerTest.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lldb/unittests/Expression/DiagnosticManagerTest.cpp b/lldb/unittests/Expression/DiagnosticManagerTest.cpp index 3cfb5ed0b66b..cab26debedb1 100644 --- a/lldb/unittests/Expression/DiagnosticManagerTest.cpp +++ b/lldb/unittests/Expression/DiagnosticManagerTest.cpp @@ -75,6 +75,9 @@ TEST(DiagnosticManagerTest, HasFixits) { TEST(DiagnosticManagerTest, GetStringNoDiags) { DiagnosticManager mgr; EXPECT_EQ("", mgr.GetString()); + std::unique_ptr<Diagnostic> empty; + mgr.AddDiagnostic(std::move(empty)); + EXPECT_EQ("", mgr.GetString()); } TEST(DiagnosticManagerTest, GetStringBasic) { |