diff options
author | Thomas Van Lenten <thomasvl@google.com> | 2020-10-02 09:46:13 -0400 |
---|---|---|
committer | Thomas Van Lenten <thomasvl@google.com> | 2020-10-02 15:34:46 -0400 |
commit | 1e750858d0a3fa31bf9e591cb065dcb031677a9b (patch) | |
tree | 18555807ca59765712874922b02dc62367eee815 /Foundation/GTMRegexTest.m | |
parent | 845205f12d5aeb0275a59259b5c658104a7d9197 (diff) |
Fix issue found via asan
Don't try to use more bytes then there are in the string.
Diffstat (limited to 'Foundation/GTMRegexTest.m')
-rw-r--r-- | Foundation/GTMRegexTest.m | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Foundation/GTMRegexTest.m b/Foundation/GTMRegexTest.m index 75f5aad..d43b731 100644 --- a/Foundation/GTMRegexTest.m +++ b/Foundation/GTMRegexTest.m @@ -885,6 +885,15 @@ XCTAssertNotNil(seg); XCTAssertGreaterThan([[seg description] length], (NSUInteger)10, @"failed to get a reasonable description for regex string segment"); + + // Truncation on the input string (and handling sort lengths) + enumerator = [regex segmentEnumeratorForString:@"aaabbbccc"]; + XCTAssertNotNil(enumerator); + XCTAssertTrue([[enumerator description] hasSuffix:@", string=\"aaabbbccc\" }"]); + enumerator = [regex segmentEnumeratorForString:@"aaabbbcccdddeeefffggghhh"]; + XCTAssertNotNil(enumerator); + XCTAssertTrue([[enumerator description] hasSuffix:@", string=\"aaabbbcccdddeeefffgg...\" }"]); + // regex w/ other options regex = [GTMRegex regexWithPattern:@"a+" options:(kGTMRegexOptionIgnoreCase | kGTMRegexOptionSupressNewlineSupport)]; |