Skip to content

Commit 44bd1e9

Browse files
committed
[lldb] Add a missing check for an empty array
rdar://152611562
1 parent cf4a54e commit 44bd1e9

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeDynamicTypeResolution.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,6 +1456,8 @@ SwiftRuntimeTypeVisitor::VisitImpl(std::optional<unsigned> visit_only,
14561456
++i;
14571457
}
14581458
}
1459+
if (supers.empty())
1460+
return llvm::createStringError("could not get instance type info");
14591461

14601462
// Handle the "real" fields.
14611463
auto *object = supers[0].get_record_type_info();

lldb/test/API/lang/swift/foundation_value_types/notification/TestSwiftFoundationTypeNotification.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,7 @@ def test(self):
3232
substrs=['name = ', '"MyNotification"',
3333
'object = nil',
3434
'userInfo = 0 key/value pairs'])
35+
name = self.frame().FindVariable("name")
36+
# This is a "don't crash" test.
37+
child = name.GetChildAtIndex(0)
38+
self.assertEquals(name.GetSummary(), '"MyNotification"')

lldb/test/API/lang/swift/foundation_value_types/notification/main.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import Foundation
22

33
func main() {
4-
var notification = Notification(name: Notification.Name(rawValue: "MyNotification"), object: nil, userInfo: [:])
4+
var name = Notification.Name(rawValue: "MyNotification")
5+
var notification = Notification(name: name, object: nil, userInfo: [:])
56
print("break here!")
67
}
78

0 commit comments

Comments
 (0)