From e641469f9ffb48a33712147a884f3f1f071dbd40 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Thu, 28 Jul 2016 18:45:13 +0200 Subject: [PATCH] jscript: Set output to undefined in jsval_copy on failure. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/jscript/dispex.c | 4 +--- dlls/jscript/jsutils.c | 8 ++++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c index 538219e3b16..cbfcc852837 100644 --- a/dlls/jscript/dispex.c +++ b/dlls/jscript/dispex.c @@ -491,10 +491,8 @@ static HRESULT prop_put(jsdisp_t *This, dispex_prop_t *prop, jsval_t val, IServi TRACE("%s = %s\n", debugstr_w(prop->name), debugstr_jsval(val)); hres = jsval_copy(val, &prop->u.val); - if(FAILED(hres)) { - prop->u.val = jsval_undefined(); + if(FAILED(hres)) return hres; - } if(This->builtin_info->on_put) This->builtin_info->on_put(This, prop->name); diff --git a/dlls/jscript/jsutils.c b/dlls/jscript/jsutils.c index dd7951067af..e7100ba0d71 100644 --- a/dlls/jscript/jsutils.c +++ b/dlls/jscript/jsutils.c @@ -212,13 +212,17 @@ static HRESULT jsval_variant(jsval_t *val, VARIANT *var) __JSVAL_TYPE(*val) = JSV_VARIANT; __JSVAL_VAR(*val) = v = heap_alloc(sizeof(VARIANT)); - if(!v) + if(!v) { + *val = jsval_undefined(); return E_OUTOFMEMORY; + } V_VT(v) = VT_EMPTY; hres = VariantCopy(v, var); - if(FAILED(hres)) + if(FAILED(hres)) { + *val = jsval_undefined(); heap_free(v); + } return hres; }