From: Dmitry Volyntsev Date: Fri, 22 May 2026 04:05:59 +0000 (-0700) Subject: QuickJS: fixed fetch error-handling typos X-Git-Tag: 1.0.0~46 X-Git-Url: http://git.kaiwu.me/postgresql/log/contrib/postgres_fdw/stylesheets/stylesheet.css?a=commitdiff_plain;h=b40fdfb467b19ee2f549dd62e6812eb6c205d0f7;p=njs.git QuickJS: fixed fetch error-handling typos Returned the JS_ThrowOutOfMemory() result from ngx_qjs_fetch_response_ctor() on ngx_list_init() failure: previously the call result was discarded and execution fell through. Replaced a stale "ret" check with "rc" after ngx_qjs_headers_fill(), so a non-NGX_OK return is no longer ignored. Added a NULL check after JS_ToCStringLen() on the header key in ngx_qjs_headers_ext_keys(), and replaced a stale "value" check with "item" when testing JS_NewStringLen() for failure. --- diff --git a/nginx/ngx_qjs_fetch.c b/nginx/ngx_qjs_fetch.c index 7c0a7a34..066088ce 100644 --- a/nginx/ngx_qjs_fetch.c +++ b/nginx/ngx_qjs_fetch.c @@ -759,7 +759,7 @@ ngx_qjs_fetch_response_ctor(JSContext *cx, JSValueConst new_target, int argc, ret = ngx_list_init(&response->headers.header_list, pool, 4, sizeof(ngx_js_tb_elt_t)); if (ret != NGX_OK) { - JS_ThrowOutOfMemory(cx); + return JS_ThrowOutOfMemory(cx); } init = argv[1]; @@ -825,7 +825,7 @@ ngx_qjs_fetch_response_ctor(JSContext *cx, JSValueConst new_target, int argc, rc = ngx_qjs_headers_fill(cx, &response->headers, value); JS_FreeValue(cx, value); - if (ret != NGX_OK) { + if (rc != NGX_OK) { return JS_EXCEPTION; } } @@ -1458,6 +1458,9 @@ ngx_qjs_headers_ext_keys(JSContext *cx, JSValue value) hdr.data = (u_char *) JS_ToCStringLen(cx, &hdr.len, key); JS_FreeValue(cx, key); + if (hdr.data == NULL) { + goto fail; + } found = h[i].key.len == hdr.len && ngx_strncasecmp(h[i].key.data, @@ -1473,7 +1476,7 @@ ngx_qjs_headers_ext_keys(JSContext *cx, JSValue value) if (k == n) { item = JS_NewStringLen(cx, (const char *) h[i].key.data, h[i].key.len); - if (JS_IsException(value)) { + if (JS_IsException(item)) { goto fail; }