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 authored and ksh8281 committed Dec 2, 2024
1 parent 2042958 commit a02c48d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
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
2 changes: 1 addition & 1 deletion test/vendortest

0 comments on commit a02c48d

Please sign in to comment.