Gabriel Ivăncescu : jscript: Store the object prototype in the script context.

Alexandre Julliard julliard at winehq.org
Thu Mar 11 15:59:36 CST 2021


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

Author: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Date:   Thu Mar 11 18:01:08 2021 +0200

jscript: Store the object prototype in the script context.

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/global.c  | 7 +++----
 dlls/jscript/jscript.c | 5 +++++
 dlls/jscript/jscript.h | 1 +
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/dlls/jscript/global.c b/dlls/jscript/global.c
index 735e188e1bd..33869cd5fc6 100644
--- a/dlls/jscript/global.c
+++ b/dlls/jscript/global.c
@@ -1055,7 +1055,7 @@ static HRESULT init_constructors(script_ctx_t *ctx, jsdisp_t *object_prototype)
 HRESULT init_global(script_ctx_t *ctx)
 {
     unsigned const_flags = ctx->version >= SCRIPTLANGUAGEVERSION_ES5 ? 0 : PROPF_WRITABLE;
-    jsdisp_t *math, *object_prototype, *constr;
+    jsdisp_t *math, *constr;
     HRESULT hres;
 
     if(ctx->global)
@@ -1065,12 +1065,11 @@ HRESULT init_global(script_ctx_t *ctx)
     if(FAILED(hres))
         return hres;
 
-    hres = create_object_prototype(ctx, &object_prototype);
+    hres = create_object_prototype(ctx, &ctx->object_prototype);
     if(FAILED(hres))
         return hres;
 
-    hres = init_constructors(ctx, object_prototype);
-    jsdisp_release(object_prototype);
+    hres = init_constructors(ctx, ctx->object_prototype);
     if(FAILED(hres))
         return hres;
 
diff --git a/dlls/jscript/jscript.c b/dlls/jscript/jscript.c
index c5c23889f04..67a25d1714b 100644
--- a/dlls/jscript/jscript.c
+++ b/dlls/jscript/jscript.c
@@ -483,6 +483,11 @@ static void decrease_state(JScript *This, SCRIPTSTATE state)
                 This->ctx->site = NULL;
             }
 
+            if(This->ctx->object_prototype) {
+                jsdisp_release(This->ctx->object_prototype);
+                This->ctx->object_prototype = NULL;
+            }
+
             if(This->ctx->global) {
                 jsdisp_release(This->ctx->global);
                 This->ctx->global = NULL;
diff --git a/dlls/jscript/jscript.h b/dlls/jscript/jscript.h
index b590e1a7441..d7d9dd7a4e3 100644
--- a/dlls/jscript/jscript.h
+++ b/dlls/jscript/jscript.h
@@ -451,6 +451,7 @@ struct _script_ctx_t {
     jsdisp_t *uri_error_constr;
     jsdisp_t *number_constr;
     jsdisp_t *object_constr;
+    jsdisp_t *object_prototype;
     jsdisp_t *regexp_constr;
     jsdisp_t *string_constr;
     jsdisp_t *vbarray_constr;




More information about the wine-cvs mailing list