Welcome! Log In Create A New Profile

Advanced

[njs] QuickJS: fixed Buffer.concat() with a single argument.

This forum is currently read only. You can not log in or make any changes. This is a temporary situation.
Anonymous User
January 22, 2025 07:08PM
details: https://github.com/nginx/njs/commit/13b37cbc9d6288b7dae79ddd73a3f152cc8ae72d
branches: master
commit: 13b37cbc9d6288b7dae79ddd73a3f152cc8ae72d
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Thu, 16 Jan 2025 17:36:44 -0800
description:
QuickJS: fixed Buffer.concat() with a single argument.


---
src/qjs_buffer.c | 2 +-
test/buffer.t.js | 9 ++++++++-
2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/qjs_buffer.c b/src/qjs_buffer.c
index 3652a07a..9840377f 100644
--- a/src/qjs_buffer.c
+++ b/src/qjs_buffer.c
@@ -158,7 +158,7 @@ static const JSCFunctionListEntry qjs_buffer_props[] = {
JS_CFUNC_MAGIC_DEF("allocUnsafe", 3, qjs_bufferobj_alloc, 1),
JS_CFUNC_DEF("byteLength", 2, qjs_buffer_byte_length),
JS_CFUNC_DEF("compare", 6, qjs_buffer_compare),
- JS_CFUNC_DEF("concat", 1, qjs_buffer_concat),
+ JS_CFUNC_DEF("concat", 2, qjs_buffer_concat),
JS_CFUNC_DEF("from", 3, qjs_buffer_from),
JS_CFUNC_DEF("isBuffer", 1, qjs_buffer_is_buffer),
JS_CFUNC_DEF("isEncoding", 1, qjs_buffer_is_encoding),
diff --git a/test/buffer.t.js b/test/buffer.t.js
index 9becf487..8e3f4ca9 100644
--- a/test/buffer.t.js
+++ b/test/buffer.t.js
@@ -79,7 +79,14 @@ let concat_tsuite = {
name: "Buffer.concat() tests",
skip: () => (!has_buffer()),
T: async (params) => {
- let r = Buffer.concat(params.buffers, params.length);
+ let r;
+
+ if (params.length) {
+ r = Buffer.concat(params.buffers, params.length);
+
+ } else {
+ r = Buffer.concat(params.buffers);
+ }

if (r.toString() !== params.expected) {
throw Error(`unexpected output "${r.toString()}" != "${params.expected}"`);
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] QuickJS: fixed Buffer.concat() with a single argument.

Anonymous User 90 January 22, 2025 07:08PM



Online Users

Guests: 242
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready