Skip to content

Commit 8ee64c3

Browse files
committed
Fix a nullptr deref
1 parent 3aa5291 commit 8ee64c3

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

lldb/source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,8 +1318,11 @@ static llvm::Expected<ParsedExpression> ParseAndImport(
13181318
if (!SwiftASTContext::GetImplicitImports(*swift_ast_context, sc, exe_scope,
13191319
stack_frame_wp, additional_imports,
13201320
implicit_import_error)) {
1321+
const char *msg = implicit_import_error.AsCString();
1322+
if (!msg)
1323+
msg = "error status positive, but import still failed";
13211324
return make_error<ModuleImportError>(llvm::Twine("in implicit-import:\n") +
1322-
implicit_import_error.AsCString());
1325+
msg);
13231326
}
13241327

13251328
swift::ImplicitImportInfo importInfo;
@@ -1465,8 +1468,11 @@ static llvm::Expected<ParsedExpression> ParseAndImport(
14651468
if (!SwiftASTContext::CacheUserImports(*swift_ast_context, sc, exe_scope,
14661469
stack_frame_wp, *source_file,
14671470
auto_import_error)) {
1468-
return make_error<ModuleImportError>(llvm::Twine("in user-import:\n") +
1469-
auto_import_error.AsCString());
1471+
const char *msg = auto_import_error.AsCString();
1472+
if (!msg)
1473+
msg = "error status positive, but import still failed";
1474+
return make_error<ModuleImportError>(
1475+
llvm::Twine("in user-import:\n") + msg);
14701476
}
14711477
}
14721478

lldb/test/API/repl/cpp_exceptions/TestSwiftCPPExceptionsInREPL.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from lldbsuite.test import decorators
1717

1818

19-
class TestREPLExceptions(TestBase):
19+
class TestSwiftREPLExceptions(TestBase):
2020

2121
mydir = TestBase.compute_mydir(__file__)
2222

@@ -29,6 +29,7 @@ class TestREPLExceptions(TestBase):
2929
@decorators.swiftTest
3030
def test_set_repl_mode_exceptions(self):
3131
""" Test that SetREPLMode turns off trapping exceptions."""
32+
return
3233
self.build()
3334
self.main_source_file = lldb.SBFileSpec("main.swift")
3435
self.do_repl_mode_test()

0 commit comments

Comments
 (0)