[njs] QuickJS: fixed ngx_qjs_string() to handle strings containing "\0".
noreply at nginx.com
noreply at nginx.com
Wed Mar 19 07:08:02 UTC 2025
details: https://github.com/nginx/njs/commit/1b7adef4d532df55d81e22ec8fe998b76de34935
branches: master
commit: 1b7adef4d532df55d81e22ec8fe998b76de34935
user: hongzhidao <hongzhidao at gmail.com>
date: Wed, 19 Mar 2025 13:47:07 +0800
description:
QuickJS: fixed ngx_qjs_string() to handle strings containing "\0".
---
nginx/ngx_js.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/nginx/ngx_js.c b/nginx/ngx_js.c
index 84cdcc2e..c91a5530 100644
--- a/nginx/ngx_js.c
+++ b/nginx/ngx_js.c
@@ -1482,13 +1482,11 @@ ngx_qjs_string(JSContext *cx, JSValueConst val, ngx_str_t *dst)
string:
- str = JS_ToCString(cx, val);
+ str = JS_ToCStringLen(cx, &len, val);
if (str == NULL) {
return NGX_ERROR;
}
- len = strlen(str);
-
start = njs_mp_alloc(e->pool, len);
if (start == NULL) {
JS_FreeCString(cx, str);
More information about the nginx-devel
mailing list