diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-08-12 16:54:59 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-08-12 16:54:59 (GMT) |
commit | 18e548c3f705fa6b4ebfac80fe79fe49dac54a0a (patch) | |
tree | dd424a23317b73f103ed3f570ab0137e511e6aa7 | |
parent | 208594091a0bfd625c463dfa872d02b1c32d6cd0 (diff) | |
download | Qt-18e548c3f705fa6b4ebfac80fe79fe49dac54a0a.zip Qt-18e548c3f705fa6b4ebfac80fe79fe49dac54a0a.tar.gz Qt-18e548c3f705fa6b4ebfac80fe79fe49dac54a0a.tar.bz2 |
Set 'this' on the javascript stack for native function
When called from the interpreter, we do not need to create a stack
frame, but we need anyway to put the newly created this on the stack.
This fixes crash in the test qscriptjstestsuite
-rw-r--r-- | src/script/api/qscriptengine.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index cc6233b..9f9242c 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -2300,6 +2300,10 @@ JSC::CallFrame *QScriptEnginePrivate::pushContext(JSC::CallFrame *exec, const JS newCallFrame[++dst] = *it; newCallFrame += argc + JSC::RegisterFile::CallFrameHeaderSize; newCallFrame->init(0, /*vPC=*/0, exec->scopeChain(), exec, 0, argc, callee); + } else if (calledAsConstructor) { + //update the new created this + JSC::Register* thisRegister = newCallFrame->registers() - JSC::RegisterFile::CallFrameHeaderSize - newCallFrame->argumentCount(); + *thisRegister = thisObject; } currentFrame = newCallFrame; QScript::QScriptActivationObject *scope = new (newCallFrame) QScript::QScriptActivationObject(newCallFrame); |