Skip to content

Commit

Permalink
Fix bugs in RegExp
Browse files Browse the repository at this point in the history
Signed-off-by: HyukWoo Park <[email protected]>
  • Loading branch information
clover2123 committed Dec 2, 2024
1 parent 2042958 commit 6d9bbf0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/runtime/RegExpObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,11 +336,15 @@ bool RegExpObject::match(ExecutionState& state, String* str, RegexMatchResult& m
WTF::BumpPointerAllocator* bumpAlloc = ThreadLocal::bumpPointerAllocator();
JSC::Yarr::ErrorCode errorCode = JSC::Yarr::ErrorCode::NoError;
std::unique_ptr<JSC::Yarr::BytecodePattern> ownedBytecode = JSC::Yarr::byteCompile(*m_yarrPattern, bumpAlloc, errorCode);
if (errorCode != JSC::Yarr::ErrorCode::NoError) {
return false;
}
m_bytecodePattern = ownedBytecode.release();
entry.m_bytecodePattern = m_bytecodePattern;
}
}

ASSERT(!!m_bytecodePattern);
unsigned subPatternNum = m_bytecodePattern->m_body->m_numSubpatterns;
matchResult.m_subPatternNum = (int)subPatternNum;
size_t length = str->length();
Expand All @@ -349,7 +353,8 @@ bool RegExpObject::match(ExecutionState& state, String* str, RegexMatchResult& m
bool isGlobal = option() & RegExpObject::Option::Global;
bool isSticky = option() & RegExpObject::Option::Sticky;
bool gotResult = false;
unsigned* outputBuf = ALLOCA(sizeof(unsigned) * 2 * (subPatternNum + 1), unsigned int);
unsigned outputBufLength = std::max((2 * (subPatternNum + 1)), m_bytecodePattern->m_offsetsSize);
unsigned* outputBuf = ALLOCA(sizeof(unsigned) * outputBufLength, unsigned int);
outputBuf[1] = start;
do {
start = outputBuf[1];
Expand Down

0 comments on commit 6d9bbf0

Please sign in to comment.