From: Dmitry Volyntsev Date: Fri, 20 Apr 2018 13:42:10 +0000 (+0300) Subject: Fixed exception type for unsupported types in JSON.stringify(). X-Git-Url: http://git.kaiwu.me/postgresql/log/contrib/postgres_fdw/static/gitweb.js?a=commitdiff_plain;h=724ae376660030e8f1c09e8d04ef9e9f86991a15;p=njs.git Fixed exception type for unsupported types in JSON.stringify(). --- diff --git a/njs/njs_json.c b/njs/njs_json.c index c7b952f9..1f704155 100644 --- a/njs/njs_json.c +++ b/njs/njs_json.c @@ -1184,6 +1184,10 @@ njs_json_parse_exception(njs_json_parse_ctx_t *ctx, const char* msg, state->written = 1; \ ret = njs_json_append_value(stringify, value); \ if (nxt_slow_path(ret != NXT_OK)) { \ + if (ret == NXT_DECLINED) { \ + return NXT_ERROR; \ + } \ + \ goto memory_error; \ } diff --git a/njs/test/njs_unit_test.c b/njs/test/njs_unit_test.c index 7fbee6a0..6478ea2e 100644 --- a/njs/test/njs_unit_test.c +++ b/njs/test/njs_unit_test.c @@ -8708,6 +8708,9 @@ static njs_unit_test_t njs_test[] = { nxt_string("var e = URIError('e'); e.foo = 'E'; JSON.stringify(e)"), nxt_string("{\"foo\":\"E\"}") }, + { nxt_string("JSON.stringify($r)"), + nxt_string("TypeError: Non-serializable object") }, + /* Ignoring named properties of an array. */ { nxt_string("var a = [1,2]; a.a = 1;"