Gabriel Ivăncescu : jscript: Use NULL in frame->this_obj for the global code object.

Alexandre Julliard julliard at winehq.org
Fri Mar 6 16:38:41 CST 2020


Module: wine
Branch: master
Commit: fcba99c52ea781ebaeb581fa4e5b00ca2b62c8ca
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=fcba99c52ea781ebaeb581fa4e5b00ca2b62c8ca

Author: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Date:   Fri Mar  6 15:48:38 2020 +0200

jscript: Use NULL in frame->this_obj for the global code object.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/jscript/engine.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c
index 7da8f707ed..3946d02da2 100644
--- a/dlls/jscript/engine.c
+++ b/dlls/jscript/engine.c
@@ -1218,12 +1218,15 @@ static HRESULT interp_call_member(script_ctx_t *ctx)
 /* ECMA-262 3rd Edition    11.1.1 */
 static HRESULT interp_this(script_ctx_t *ctx)
 {
-    call_frame_t *frame = ctx->call_ctx;
+    IDispatch *this_obj = ctx->call_ctx->this_obj;
 
     TRACE("\n");
 
-    IDispatch_AddRef(frame->this_obj);
-    return stack_push(ctx, jsval_disp(frame->this_obj));
+    if(!this_obj)
+        this_obj = ctx->host_global ? ctx->host_global : to_disp(ctx->global);
+
+    IDispatch_AddRef(this_obj);
+    return stack_push(ctx, jsval_disp(this_obj));
 }
 
 static HRESULT interp_identifier_ref(script_ctx_t *ctx, BSTR identifier, unsigned flags)
@@ -2700,7 +2703,7 @@ static void print_backtrace(script_ctx_t *ctx)
         WARN("%u\t", depth);
         depth++;
 
-        if(frame->this_obj && frame->this_obj != to_disp(ctx->global) && frame->this_obj != ctx->host_global)
+        if(frame->this_obj)
             WARN("%p->", frame->this_obj);
         WARN("%s(", frame->function->name ? debugstr_w(frame->function->name) : "[unnamed]");
         if(frame->base_scope && frame->base_scope->frame) {
@@ -3055,13 +3058,10 @@ HRESULT exec_source(script_ctx_t *ctx, DWORD flags, bytecode_t *bytecode, functi
 
     frame->ip = function->instr_off;
     frame->stack_base = ctx->stack_top;
-    if(this_obj)
+    if(this_obj) {
         frame->this_obj = this_obj;
-    else if(ctx->host_global)
-        frame->this_obj = ctx->host_global;
-    else
-        frame->this_obj = to_disp(ctx->global);
-    IDispatch_AddRef(frame->this_obj);
+        IDispatch_AddRef(frame->this_obj);
+    }
 
     if(function_instance)
         frame->function_instance = jsdisp_addref(function_instance);




More information about the wine-cvs mailing list