diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2019-01-08 09:17:21 +0100 |
---|---|---|
committer | Jani Heikkinen <jani.heikkinen@qt.io> | 2019-01-09 09:30:10 +0000 |
commit | 09e3e5438182de606ecbd8f352eddc482f78891f (patch) | |
tree | 543acdc9e5f98c3d1c30829d262865c8d70b9ef9 /src/qml/jsruntime/qv4regexpobject.cpp | |
parent | c2c012f79438d207cc95237c90b692121acc4876 (diff) |
When matching RegExps catch JIT failures
The Yarr JIT can generate code that fails to evaluate the RegExp at
runtime. In that case we need to fall back to the interpreter.
Also, don't needlessly cast the unsigned return value of RegExp::match
to signed int before range-checking it. And fix some typos in the
comments for the disassembler dumps.
Fixes: QTBUG-72879
Change-Id: Ic8f80c076d6461d714816a9f66e1cac1d9b0c7a8
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4regexpobject.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4regexpobject.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp index 9df286065d..39a2e96b45 100644 --- a/src/qml/jsruntime/qv4regexpobject.cpp +++ b/src/qml/jsruntime/qv4regexpobject.cpp @@ -181,17 +181,19 @@ ReturnedValue RegExpObject::builtinExec(ExecutionEngine *engine, const String *s } Q_ALLOCA_VAR(uint, matchOffsets, value()->captureCount() * 2 * sizeof(uint)); - const int result = Scoped<RegExp>(scope, value())->match(s, offset, matchOffsets); + const uint result = Scoped<RegExp>(scope, value())->match(s, offset, matchOffsets); RegExpCtor *regExpCtor = static_cast<RegExpCtor *>(scope.engine->regExpCtor()); regExpCtor->d()->clearLastMatch(); - if (result == -1) { + if (result == JSC::Yarr::offsetNoMatch) { if (global() || sticky()) setLastIndex(0); RETURN_RESULT(Encode::null()); } + Q_ASSERT(result <= uint(std::numeric_limits<int>::max())); + // fill in result data ScopedArrayObject array(scope, scope.engine->newArrayObject(scope.engine->internalClasses(EngineBase::Class_RegExpExecArray))); int len = value()->captureCount(); @@ -207,7 +209,7 @@ ReturnedValue RegExpObject::builtinExec(ExecutionEngine *engine, const String *s array->arrayPut(i, v); } array->setArrayLengthUnchecked(len); - array->setProperty(Index_ArrayIndex, Value::fromInt32(result)); + array->setProperty(Index_ArrayIndex, Value::fromInt32(int(result))); array->setProperty(Index_ArrayInput, *str); RegExpCtor::Data *dd = regExpCtor->d(); |