mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 872971 - Clamp regexp quantifiers to INT_MAX. r=jandem
This commit is contained in:
parent
bb2550d1e4
commit
b118028370
@ -10,3 +10,8 @@ reportCompare(["a", ""].toSource(), toSource(/((?:.)*?)a/.exec("a")));
|
||||
reportCompare(["a", ""].toSource(), toSource(/a((?:.)*)/.exec("a")));
|
||||
|
||||
reportCompare(["B", "B"].toSource(), toSource(/([A-Z])/.exec("fooBar")));
|
||||
|
||||
// These just mustn't crash. See bug 872971
|
||||
reportCompare(/x{2147483648}x/.test('1'), false);
|
||||
reportCompare(/x{2147483648,}x/.test('1'), false);
|
||||
reportCompare(/x{2147483647,2147483648}x/.test('1'), false);
|
||||
|
@ -612,12 +612,23 @@ private:
|
||||
unsigned min;
|
||||
if (!consumeNumber(min))
|
||||
break;
|
||||
// Clamping to INT_MAX is technically a spec deviation. In practice, it's
|
||||
// undetectable, because we can't even allocate strings large enough for
|
||||
// quantifiers this large to ever create different results than smaller ones.
|
||||
if (min > INT_MAX)
|
||||
min = INT_MAX;
|
||||
|
||||
unsigned max = min;
|
||||
if (tryConsume(',')) {
|
||||
if (peekIsDigit()) {
|
||||
if (!consumeNumber(max))
|
||||
break;
|
||||
// Clamping to INT_MAX is technically a spec deviation. In practice,
|
||||
// it's undetectable, because we can't even allocate strings large
|
||||
// enough for quantifiers this large to ever create different results
|
||||
// than smaller ones.
|
||||
if (max > INT_MAX)
|
||||
max = INT_MAX;
|
||||
} else {
|
||||
max = quantifyInfinite;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user