diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-11-06 16:14:46 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2017-11-15 18:46:46 +0000 |
commit | 6b738e3224c26fcce148b569188e2a25520e54d6 (patch) | |
tree | be505078357b95574d6b59f6832bfa78cf3a63e6 /src/qml/jsruntime/qv4vme_moth.cpp | |
parent | 557ea845157d4f6b757ec2eebbc71e1af9910cc6 (diff) |
Don't copy unnamed arguments onto the JS stack
These can only be referenced through the arguments
objects, and have so far messed up initialization
of local variables.
Change-Id: I3100520ed55c93204dd7953da8cc3d2b7d200d11
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4vme_moth.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4vme_moth.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index 9eb51763ca..9159f55245 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -530,11 +530,13 @@ QV4::ReturnedValue VME::exec(const FunctionObject *fo, const Value *thisObject, callData->context = scope; callData->accumulator = Encode::undefined(); callData->thisObject = thisObject ? *thisObject : Primitive::undefinedValue(); + if (argc > int(function->nFormals)) + argc = int(function->nFormals); callData->setArgc(argc); int jsStackFrameSize = offsetof(CallData, args)/sizeof(Value) + function->compiledFunction->nRegisters; engine->jsStackTop += jsStackFrameSize; - memcpy(callData->args, argv, argc*sizeof(Value)); // ### Fixme: only copy nFormals + memcpy(callData->args, argv, argc*sizeof(Value)); for (Value *v = callData->args + argc; v < engine->jsStackTop; ++v) *v = Encode::undefined(); @@ -849,8 +851,7 @@ QV4::ReturnedValue VME::exec(const FunctionObject *fo, const Value *thisObject, MOTH_END_INSTR(PushCatchContext) MOTH_BEGIN_INSTR(CreateCallContext) - Heap::ExecutionContext *ctx = static_cast<Heap::ExecutionContext *>(stack[CallData::Context].m()); - stack[CallData::Context] = ExecutionContext::newCallContext(ctx, function, reinterpret_cast<CallData *>(stack)); + stack[CallData::Context] = ExecutionContext::newCallContext(&frame); MOTH_END_INSTR(CreateCallContext) MOTH_BEGIN_INSTR(PushWithContext) |