Skip to content

Commit ba3973b

Browse files
ylnJulian Lettner
andauthored
[SUA] Do not access the field descriptor when absent (swiftlang#63663)
Radar-Id: rdar://105461946 Co-authored-by: Julian Lettner <[email protected]>
1 parent 9f92220 commit ba3973b

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

stdlib/public/runtime/HeapObject.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,15 @@ computeMallocTypeSummary(const HeapMetadata *heapMetadata) {
143143
summary.type_kind = MALLOC_TYPE_KIND_SWIFT;
144144

145145
bool isGenericData = true;
146-
for (auto &field : *typeDesc->Fields.get()) {
147-
if (field.isIndirectCase()) {
148-
isGenericData = false;
149-
if (field.isVar())
150-
summary.layout_semantics.data_pointer = true;
151-
else
152-
summary.layout_semantics.immutable_pointer = true;
146+
if (auto *fieldDesc = typeDesc->Fields.get()) {
147+
for (auto &field : *fieldDesc) {
148+
if (field.isIndirectCase()) {
149+
isGenericData = false;
150+
if (field.isVar())
151+
summary.layout_semantics.data_pointer = true;
152+
else
153+
summary.layout_semantics.immutable_pointer = true;
154+
}
153155
}
154156
}
155157

0 commit comments

Comments
 (0)