diff --git a/dlls/jscript/array.c b/dlls/jscript/array.c index 1ced39e2ca9..1268d59638b 100644 --- a/dlls/jscript/array.c +++ b/dlls/jscript/array.c @@ -166,7 +166,7 @@ static HRESULT concat_array(DispatchEx *array, ArrayInstance *obj, DWORD *len, HRESULT hres; for(i=0; i < obj->length; i++) { - hres = jsdisp_propget_idx(&obj->dispex, i, &var, ei, caller); + hres = jsdisp_get_idx(&obj->dispex, i, &var, ei, caller); if(hres == DISP_E_UNKNOWNNAME) continue; if(FAILED(hres)) @@ -267,8 +267,11 @@ static HRESULT array_join(script_ctx_t *ctx, DispatchEx *array, DWORD length, co return E_OUTOFMEMORY; for(i=0; i < length; i++) { - hres = jsdisp_propget_idx(array, i, &var, ei, caller); - if(FAILED(hres)) + hres = jsdisp_get_idx(array, i, &var, ei, caller); + if(hres == DISP_E_UNKNOWNNAME) { + hres = S_OK; + continue; + } else if(FAILED(hres)) break; if(V_VT(&var) != VT_EMPTY && V_VT(&var) != VT_NULL) @@ -397,7 +400,7 @@ static HRESULT Array_pop(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPARA } length--; - hres = jsdisp_propget_idx(jsthis, length, &val, ei, caller); + hres = jsdisp_get_idx(jsthis, length, &val, ei, caller); if(SUCCEEDED(hres)) { hres = jsdisp_delete_idx(jsthis, length); } else if(hres == DISP_E_UNKNOWNNAME) { @@ -472,11 +475,11 @@ static HRESULT Array_reverse(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISP for(k=0; k delete_cnt) { for(i=length-delete_cnt; SUCCEEDED(hres) && i != start; i--) { - hres = jsdisp_propget_idx(jsthis, i+delete_cnt-1, &v, ei, caller); + hres = jsdisp_get_idx(jsthis, i+delete_cnt-1, &v, ei, caller); if(hres == DISP_E_UNKNOWNNAME) hres = jsdisp_delete_idx(jsthis, i+add_args-1); else if(SUCCEEDED(hres)) diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c index 1b52ba49596..492623e18bb 100644 --- a/dlls/jscript/dispex.c +++ b/dlls/jscript/dispex.c @@ -1003,14 +1003,26 @@ HRESULT jsdisp_propget_name(DispatchEx *obj, const WCHAR *name, VARIANT *var, js return prop_get(obj, prop, &dp, var, ei, caller); } -HRESULT jsdisp_propget_idx(DispatchEx *obj, DWORD idx, VARIANT *var, jsexcept_t *ei, IServiceProvider *caller) +HRESULT jsdisp_get_idx(DispatchEx *obj, DWORD idx, VARIANT *var, jsexcept_t *ei, IServiceProvider *caller) { - WCHAR buf[12]; + WCHAR name[12]; + DISPPARAMS dp = {NULL, NULL, 0, 0}; + dispex_prop_t *prop; + HRESULT hres; static const WCHAR formatW[] = {'%','d',0}; - sprintfW(buf, formatW, idx); - return jsdisp_propget_name(obj, buf, var, ei, caller); + sprintfW(name, formatW, idx); + + hres = find_prop_name_prot(obj, name, FALSE, &prop); + if(FAILED(hres)) + return hres; + + V_VT(var) = VT_EMPTY; + if(!prop) + return DISP_E_UNKNOWNNAME; + + return prop_get(obj, prop, &dp, var, ei, caller); } HRESULT jsdisp_propget(DispatchEx *jsdisp, DISPID id, VARIANT *val, jsexcept_t *ei, IServiceProvider *caller) diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c index d25fd0fc295..c7494cfce6c 100644 --- a/dlls/jscript/function.c +++ b/dlls/jscript/function.c @@ -374,8 +374,10 @@ static HRESULT array_to_args(script_ctx_t *ctx, DispatchEx *arg_array, jsexcept_ return E_OUTOFMEMORY; for(i=0; i