Gabriel Ivăncescu : jscript: Check for null instance prototype.

Alexandre Julliard julliard at winehq.org
Wed Mar 10 14:58:47 CST 2021


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

Author: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Date:   Fri Mar  5 18:59:41 2021 +0200

jscript: Check for null instance prototype.

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/dispex.c      |  2 +-
 dlls/jscript/tests/lang.js | 15 +++++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c
index efe8741f3c1..f3eba68b9a4 100644
--- a/dlls/jscript/dispex.c
+++ b/dlls/jscript/dispex.c
@@ -1853,7 +1853,7 @@ HRESULT init_dispex_from_constr(jsdisp_t *dispex, script_ctx_t *ctx, const built
             return hres;
         }
 
-        if(is_object_instance(val))
+        if(is_object_instance(val) && get_object(val))
             prot = iface_to_jsdisp(get_object(val));
         jsval_release(val);
     }
diff --git a/dlls/jscript/tests/lang.js b/dlls/jscript/tests/lang.js
index 753b4ee595e..211ae2f0373 100644
--- a/dlls/jscript/tests/lang.js
+++ b/dlls/jscript/tests/lang.js
@@ -1864,6 +1864,21 @@ ok(tmp === "VT_DISPATCH", "getVT(Object(nullDisp) = " + tmp);
 tmp = Object(nullDisp).toString();
 ok(tmp === "[object Object]", "Object(nullDisp).toString() = " + tmp);
 
+function testNullPrototype() {
+    this.x = 13;
+}
+tmp = new testNullPrototype();
+ok(tmp.x === 13, "tmp.x !== 13");
+ok(!("y" in tmp), "tmp has 'y' property");
+testNullPrototype.prototype.y = 10;
+ok("y" in tmp, "tmp does not have 'y' property");
+tmp = new testNullPrototype();
+ok(tmp.y === 10, "tmp.y !== 10");
+testNullPrototype.prototype = nullDisp;
+tmp = new testNullPrototype();
+ok(tmp.x === 13, "tmp.x !== 13");
+ok(!("y" in tmp), "tmp has 'y' property");
+
 function do_test() {}
 function nosemicolon() {} nosemicolon();
 function () {} nosemicolon();




More information about the wine-cvs mailing list