diff options
author | Lars Knoll <[email protected]> | 2017-08-04 19:11:11 +0200 |
---|---|---|
committer | Lars Knoll <[email protected]> | 2017-08-08 18:58:02 +0000 |
commit | 8abb6c41bf055d59c6b57a809e3b027293568848 (patch) | |
tree | d427aa3798277376f29aef7e63dcee7d9e99c054 /src/qml/jsruntime | |
parent | 75f1c298ec500172a6212850365f011a5e967c3a (diff) |
Fix occasional crashes
The accumulator needs to live on the JS stack when we call into
other functions, as the object in there could otherwise get
collected.
Change-Id: I67fc71af6032cf2468214986e678ee762bc4ebfd
Reviewed-by: Simon Hausmann <[email protected]>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r-- | src/qml/jsruntime/qv4vme_moth.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index 954b7d40a1..be79cac636 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -451,17 +451,16 @@ QV4::ReturnedValue VME::exec(Function *function) frame.v4Function = function; engine->currentStackFrame = &frame; - QV4::Value accumulator = Primitive::undefinedValue(); QV4::Value *stack = nullptr; const uchar *exceptionHandler = 0; QV4::Scope scope(engine); - { - int nFormals = function->nFormals; - stack = scope.alloc(function->compiledFunction->nRegisters + nFormals + 1); - memcpy(stack, &engine->current->callData->thisObject, (nFormals + 1)*sizeof(Value)); - stack += nFormals + 1; - } + int nFormals = function->nFormals; + stack = scope.alloc(function->compiledFunction->nRegisters + nFormals + 2); + QV4::Value &accumulator = *stack; + ++stack; + memcpy(stack, &engine->current->callData->thisObject, (nFormals + 1)*sizeof(Value)); + stack += nFormals + 1; if (QV4::Debugging::Debugger *debugger = engine->debugger()) debugger->enteringFunction(); |