mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[SourceKitSwiftLang] Avoid call with null this
If an imported Objective-C method had no owning clang module, passCursorInfoForDecl() would call clang::Module::getFullModuleName() on a null instance. The current implementation of this method happens to terminate its loop immediately and return an empty string, but it’s best not to depend on this. Fixes a UBSan error in SourceKit/Mixed/cursor_mixed_header.swift.
This commit is contained in:
@@ -873,7 +873,8 @@ static bool passCursorInfoForDecl(SourceFile* SF,
|
||||
auto ClangNode = VD->getClangNode();
|
||||
if (ClangNode) {
|
||||
auto ClangMod = Importer->getClangOwningModule(ClangNode);
|
||||
ModuleName = ClangMod->getFullModuleName();
|
||||
if (ClangMod)
|
||||
ModuleName = ClangMod->getFullModuleName();
|
||||
} else if (VD->getLoc().isInvalid() && VD->getModuleContext() != MainModule) {
|
||||
ModuleName = VD->getModuleContext()->getName().str();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user