[lldb] Fix a crasher when using the public API. (#80508)

A user found a crash when they would do code like:
```
(lldb) script
>>> target = lldb.SBTarget()
>>> lldb.debugger.SetSelectedTarget(target)
```

We were not checking if the target was valid in and it caused a crash..
This commit is contained in:
Greg Clayton
2024-02-06 13:53:29 -08:00
committed by GitHub
parent c8a97c0f30
commit 1dd9162b95
2 changed files with 13 additions and 3 deletions

View File

@@ -526,3 +526,9 @@ class TargetAPITestCase(TestBase):
target.IsLoaded(module),
"Running the target should " "have loaded its modules.",
)
@no_debug_info_test
def test_setting_selected_target_with_invalid_target(self):
"""Make sure we don't crash when trying to select invalid target."""
target = lldb.SBTarget()
self.dbg.SetSelectedTarget(target)