aboutsummaryrefslogtreecommitdiff
path: root/nginx/ngx_http_js_module.c
diff options
context:
space:
mode:
authorDmitry Volyntsev <xeioex@nginx.com>2025-02-19 17:36:46 -0800
committerDmitry Volyntsev <xeioexception@gmail.com>2025-02-20 10:17:00 -0800
commit1b451958979d38dc162cfa2872197fcba9381f7d (patch)
tree08dbbfdf95da2a34daa5eefb6766cc0545ace9d6 /nginx/ngx_http_js_module.c
parent13f0787fc52e36ae5ed67add0a14c412b3c7b716 (diff)
downloadnjs-1b451958979d38dc162cfa2872197fcba9381f7d.tar.gz
njs-1b451958979d38dc162cfa2872197fcba9381f7d.zip
QuickJS: fixed memory leak in js_periodic handler.
Diffstat (limited to 'nginx/ngx_http_js_module.c')
-rw-r--r--nginx/ngx_http_js_module.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/nginx/ngx_http_js_module.c b/nginx/ngx_http_js_module.c
index 7cd87401..cdc668c5 100644
--- a/nginx/ngx_http_js_module.c
+++ b/nginx/ngx_http_js_module.c
@@ -355,6 +355,7 @@ static ngx_http_request_t *ngx_http_qjs_request(JSValueConst val);
static JSValue ngx_http_qjs_request_make(JSContext *cx, ngx_int_t proto_id,
ngx_http_request_t *r);
static void ngx_http_qjs_request_finalizer(JSRuntime *rt, JSValue val);
+static void ngx_http_qjs_periodic_finalizer(JSRuntime *rt, JSValue val);
#endif
static ngx_pool_t *ngx_http_js_pool(ngx_http_request_t *r);
@@ -1097,7 +1098,7 @@ static JSClassDef ngx_http_qjs_request_class = {
static JSClassDef ngx_http_qjs_periodic_class = {
"PeriodicSession",
- .finalizer = NULL,
+ .finalizer = ngx_http_qjs_periodic_finalizer,
};
@@ -7553,6 +7554,20 @@ ngx_http_qjs_request_finalizer(JSRuntime *rt, JSValue val)
}
+static void
+ngx_http_qjs_periodic_finalizer(JSRuntime *rt, JSValue val)
+{
+ ngx_http_qjs_request_t *req;
+
+ req = JS_GetOpaque(val, NGX_QJS_CLASS_ID_HTTP_PERIODIC);
+ if (req == NULL) {
+ return;
+ }
+
+ js_free_rt(rt, req);
+}
+
+
static ngx_engine_t *
ngx_engine_qjs_clone(ngx_js_ctx_t *ctx, ngx_js_loc_conf_t *cf,
njs_int_t proto_id, void *external)