Skip to content

Commit b0a419b

Browse files
author
Davide Italiano
committed
[IRGen] Check if VTable isn't a nullptr.
Fixes a ubsan error on the lldb bots runtime error: member call on null pointer of type 'swift::SILVTable' undefined-behavior lib/IRGen/GenMeta.cpp:5107:24
1 parent 8248f9c commit b0a419b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/IRGen/ClassMetadataVisitor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ template <class Impl> class ClassMetadataVisitor
171171
friend SILVTableVisitor<Impl>;
172172
void addMethod(SILDeclRef declRef) {
173173
// Does this method require a reified runtime vtable entry?
174-
if (methodRequiresReifiedVTableEntry(IGM, VTable, declRef)) {
174+
if (!VTable || methodRequiresReifiedVTableEntry(IGM, VTable, declRef)) {
175175
asImpl().addReifiedVTableEntry(declRef);
176176
}
177177
}

lib/IRGen/GenMeta.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1440,7 +1440,7 @@ namespace {
14401440
}
14411441

14421442
void addMethod(SILDeclRef fn) {
1443-
if (methodRequiresReifiedVTableEntry(IGM, VTable, fn)) {
1443+
if (!VTable || methodRequiresReifiedVTableEntry(IGM, VTable, fn)) {
14441444
VTableEntries.push_back(fn);
14451445
} else if (getType()->getEffectiveAccess() >= AccessLevel::Public) {
14461446
// Emit a stub method descriptor and lookup function for nonoverridden

0 commit comments

Comments
 (0)