From 5f9f9a45e9afe84dbcf69b9cb813dc983a70a7cc Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Thu, 1 Mar 2018 23:58:17 +0100 Subject: [PATCH] jscript: Properly support missing array elements in stringify_array. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/jscript/json.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/dlls/jscript/json.c b/dlls/jscript/json.c index 7d69cf55ad9..fc23b54c0de 100644 --- a/dlls/jscript/json.c +++ b/dlls/jscript/json.c @@ -545,15 +545,18 @@ static HRESULT stringify_array(stringify_ctx_t *ctx, jsdisp_t *obj) } hres = jsdisp_get_idx(obj, i, &val); - if(FAILED(hres)) + if(SUCCEEDED(hres)) { + hres = stringify(ctx, val); + if(FAILED(hres)) + return hres; + if(hres == S_FALSE && !append_string(ctx, nullW)) + return E_OUTOFMEMORY; + }else if(hres == DISP_E_UNKNOWNNAME) { + if(!append_string(ctx, nullW)) + return E_OUTOFMEMORY; + }else { return hres; - - hres = stringify(ctx, val); - if(FAILED(hres)) - return hres; - - if(hres == S_FALSE && !append_string(ctx, nullW)) - return E_OUTOFMEMORY; + } } if((length && *ctx->gap && !append_char(ctx, '\n')) || !append_char(ctx, ']'))