Welcome! Log In Create A New Profile

Advanced

[njs] Shell: fixed njs_vm_value_dump() for empty string values.

Dmitry Volyntsev
April 18, 2019 08:22AM
details: https://hg.nginx.org/njs/rev/108ef0cd302d
branches:
changeset: 901:108ef0cd302d
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Thu Apr 18 15:05:27 2019 +0300
description:
Shell: fixed njs_vm_value_dump() for empty string values.

This closes #139 issue on Github.

diffstat:

njs/njs_json.c | 16 +++++++++-------
njs/test/njs_expect_test.exp | 2 ++
2 files changed, 11 insertions(+), 7 deletions(-)

diffs (40 lines):

diff -r 9c67f7d03672 -r 108ef0cd302d njs/njs_json.c
--- a/njs/njs_json.c Wed Apr 17 21:12:21 2019 +0300
+++ b/njs/njs_json.c Thu Apr 18 15:05:27 2019 +0300
@@ -1961,15 +1961,17 @@ njs_json_buf_append(njs_json_stringify_t
{
u_char *p;

- p = njs_json_buf_reserve(stringify, len);
- if (nxt_slow_path(p == NULL)) {
- return NXT_ERROR;
+ if (len != 0) {
+ p = njs_json_buf_reserve(stringify, len);
+ if (nxt_slow_path(p == NULL)) {
+ return NXT_ERROR;
+ }
+
+ memcpy(p, msg, len);
+
+ njs_json_buf_written(stringify, len);
}

- memcpy(p, msg, len);
-
- njs_json_buf_written(stringify, len);
-
return NXT_OK;
}

diff -r 9c67f7d03672 -r 108ef0cd302d njs/test/njs_expect_test.exp
--- a/njs/test/njs_expect_test.exp Wed Apr 17 21:12:21 2019 +0300
+++ b/njs/test/njs_expect_test.exp Thu Apr 18 15:05:27 2019 +0300
@@ -188,6 +188,8 @@ njs_test {
njs_test {
{"console.log()\r\n"
"console.log()\r\nundefined\r\n>> "}
+ {"console.log('')\r\n"
+ "console.log('')\r\n\r\nundefined\r\n>> "}
{"console.log(1)\r\n"
"console.log(1)\r\n1\r\nundefined\r\n>> "}
{"console.log(1, 'a')\r\n"
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Shell: fixed njs_vm_value_dump() for empty string values.

Dmitry Volyntsev 362 April 18, 2019 08:22AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 304
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready