Skip to content

Commit 463c873

Browse files
committed
fix2.
1 parent dd0a0b8 commit 463c873

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

Diff for: nginx/ngx_qjs_fetch.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1304,7 +1304,7 @@ ngx_qjs_ext_fetch_response_body(JSContext *cx, JSValueConst this_val,
13041304

13051305
switch (magic) {
13061306
case NGX_QJS_BODY_ARRAY_BUFFER:
1307-
result = qjs_new_array_buffer(cx, string.start, string.length);
1307+
result = qjs_new_array_buffer_copy(cx, string.start, string.length);
13081308
if (JS_IsException(result)) {
13091309
return JS_ThrowOutOfMemory(cx);
13101310
}

Diff for: src/qjs.c

+7
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,13 @@ qjs_new_array_buffer(JSContext *cx, uint8_t *src, size_t len)
10091009
}
10101010

10111011

1012+
JSValue
1013+
qjs_new_array_buffer_copy(JSContext *cx, uint8_t *src, size_t len)
1014+
{
1015+
return JS_NewArrayBufferCopy(cx, src, len);
1016+
}
1017+
1018+
10121019
JSValue
10131020
qjs_string_create_chb(JSContext *cx, njs_chb_t *chain)
10141021
{

Diff for: src/qjs.h

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ JSContext *qjs_new_context(JSRuntime *rt, qjs_module_t **addons);
6767

6868
JSValue qjs_new_uint8_array(JSContext *ctx, int argc, JSValueConst *argv);
6969
JSValue qjs_new_array_buffer(JSContext *cx, uint8_t *src, size_t len);
70+
JSValue qjs_new_array_buffer_copy(JSContext *cx, uint8_t *src, size_t len);
7071
JSValue qjs_buffer_alloc(JSContext *ctx, size_t size);
7172
JSValue qjs_buffer_create(JSContext *ctx, u_char *start, size_t size);
7273
JSValue qjs_buffer_chb_alloc(JSContext *ctx, njs_chb_t *chain);

0 commit comments

Comments
 (0)