[PATCH v2 1/2] jscript: Check for null instance prototype.

Gabriel Ivăncescu gabrielopcode at gmail.com
Fri Mar 5 10:59:41 CST 2021


Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---

v2: Add tests.

 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 5829ceb..9d0357e 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 753b4ee..211ae2f 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();
-- 
2.30.0




More information about the wine-devel mailing list