Skip to content

Commit

Permalink
jscript: Avoid crash when calling stringify() with no arguments.
Browse files Browse the repository at this point in the history
Signed-off-by: Zebediah Figura <[email protected]>
Signed-off-by: Jacek Caban <[email protected]>
Signed-off-by: Alexandre Julliard <[email protected]>
  • Loading branch information
zfigura authored and julliard committed May 7, 2018
1 parent 2e9b179 commit bf47aeb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions dlls/jscript/json.c
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,12 @@ static HRESULT JSON_stringify(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un

TRACE("\n");

if(!argc) {
if(r)
*r = jsval_undefined();
return S_OK;
}

if(argc >= 2 && is_object_instance(argv[1])) {
FIXME("Replacer %s not yet supported\n", debugstr_jsval(argv[1]));
return E_NOTIMPL;
Expand Down
4 changes: 4 additions & 0 deletions dlls/jscript/tests/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -1810,6 +1810,7 @@ ok(isNaN(tmp), "Math.tan(-Infinity) is not NaN");
return;

var stringify_tests = [
[[], undefined],
[[true], "true"],
[[false], "false"],
[[null], "null"],
Expand All @@ -1836,6 +1837,9 @@ ok(isNaN(tmp), "Math.tan(-Infinity) is not NaN");
"["+i+"] stringify(" + stringify_tests[i][0] + ") returned " + s + " expected " + stringify_tests[i][1]);
}

s = JSON.stringify();
ok(s === undefined, "stringify() returned " + s + " expected undefined");

s = JSON.stringify(testObj);
ok(s === undefined || s === "undefined" /* broken on some old versions */,
"stringify(testObj) returned " + s + " expected undfined");
Expand Down

0 comments on commit bf47aeb

Please sign in to comment.