Skip to content

Commit 80c4b73

Browse files
committed
Swlft: force canonical type computation before using the type
`getCanonicalType` will force computation of the canonical type. Without canonical type computed. `getString` may cause crashes in certain cases.
1 parent 3f0be47 commit 80c4b73

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

swift/extractor/translators/TypeTranslator.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,10 @@ void TypeTranslator::fillAnyGenericType(const swift::AnyGenericType& type,
163163
}
164164

165165
void TypeTranslator::fillType(const swift::TypeBase& type, codeql::Type& entry) {
166-
entry.name = type.getString();
166+
// Preserve the order as getCanonicalType() forces computation of the canonical type
167+
// without which getString may crash sometimes
167168
entry.canonical_type = dispatcher.fetchLabel(type.getCanonicalType());
169+
entry.name = type.getString();
168170
}
169171

170172
void TypeTranslator::fillArchetypeType(const swift::ArchetypeType& type, ArchetypeType& entry) {

0 commit comments

Comments
 (0)