Skip to content

Conversation

@pushkarnk
Copy link
Member

This is the proposed fix for https://bugs.swift.org/browse/SR-1003

The function _CFRegularExpressionEnumerateMatchesInString() walks the text
searching for occurrences of the pattern. For every occurrence, it populates
a CFRange array. If the number of capture groups is not greater than 7, it
uses an array on the stack (instead of mallocing one). However, the total
number of CFRanges inserted is (number of capture groups + 1). The last
insert can corrupt the stack if the number of capture groups is 7 and change the
values of other locals leading to unexplained behaviour.

The function _CFRegularExpressionEnumerateMatchesInString() walks the text
searching for occurrences of the pattern. For every occurrence, it populates
a CFRange array. If the number of capture groups is not greater than 7, it
uses an array on the stack (instead of mallocing one). However, the total
number of CFRanges inserted is (number of capture groups + 1). The last
insert can corrupt the stack if the number of capture groups is 7.
@phausler phausler merged commit fc1ef5d into swiftlang:master Mar 30, 2016
@pushkarnk pushkarnk deleted the sr-1003 branch April 12, 2016 13:30
atrick pushed a commit to atrick/swift-corelibs-foundation that referenced this pull request Jan 12, 2021
[gardening] Fix warning about strerror return value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants