Skip to content

Commit 49c8cca

Browse files
committed
Add a test for trying to construct a Data from an invalid NSString, and fix existing invalid NSString construction
1 parent 69eab55 commit 49c8cca

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

test/stdlib/Inputs/FoundationBridge/FoundationBridge.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ static inline BOOL NSStringBridgeTestEqual(NSString * _Nonnull a, NSString * _No
8686
}
8787

8888
static inline NSString *getNSStringWithUnpairedSurrogate() {
89-
unichar chars[16] = {
89+
unichar chars[19] = {
9090
0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
9191
0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
9292
0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
9393
0xD800 };
94-
return [NSString stringWithCharacters:chars length:1];
94+
return [NSString stringWithCharacters:chars length:19];
9595
}
9696

9797
NS_ASSUME_NONNULL_END

test/stdlib/TestNSString.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class TestNSString : TestNSStringSuper {
6060
func test_unpairedSurrogates() {
6161
let evil = getNSStringWithUnpairedSurrogate();
6262
print("\(evil)")
63+
print(evil.data(using: .utf8))
6364
}
6465

6566
}

0 commit comments

Comments
 (0)