Skip to content

Commit e657a34

Browse files
AZero13Alexey Shvayka
authored andcommitted
startFrom parameter should be unsigned
https://bugs.webkit.org/show_bug.cgi?id=255527 Reviewed by Alexey Shvayka. The value being passed as this argument always unsigned anyway, and when used within the match function itself, it is always being passed to another method or function, which takes an unsigned value, not a signed one. * Source/JavaScriptCore/yarr/RegularExpression.cpp: (JSC::Yarr::RegularExpression::match const): (JSC::Yarr::replace): * Source/JavaScriptCore/yarr/RegularExpression.h: Canonical link: https://commits.webkit.org/273319@main
1 parent c1f8a9e commit e657a34

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎Source/JavaScriptCore/yarr/RegularExpression.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ RegularExpression& RegularExpression::operator=(const RegularExpression& re)
9595
return *this;
9696
}
9797

98-
int RegularExpression::match(StringView str, int startFrom, int* matchLength) const
98+
int RegularExpression::match(StringView str, unsigned startFrom, int* matchLength) const
9999
{
100100
if (!d->m_regExpByteCode)
101101
return -1;
@@ -174,9 +174,9 @@ void replace(String& string, const RegularExpression& target, StringView replace
174174
if (index < 0)
175175
break;
176176
string = makeStringByReplacing(string, index, matchLength, replacement);
177-
index += replacement.length();
178177
if (!matchLength)
179178
break; // Avoid infinite loop on 0-length matches, e.g. [a-z]*
179+
index += replacement.length();
180180
}
181181
}
182182

‎Source/JavaScriptCore/yarr/RegularExpression.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class JS_EXPORT_PRIVATE RegularExpression {
4141
RegularExpression(const RegularExpression&);
4242
RegularExpression& operator=(const RegularExpression&);
4343

44-
int match(StringView, int startFrom = 0, int* matchLength = nullptr) const;
44+
int match(StringView, unsigned startFrom = 0, int* matchLength = nullptr) const;
4545
int searchRev(StringView) const;
4646

4747
int matchedLength() const;

0 commit comments

Comments
 (0)