diff options
author | Dmitry Volyntsev <xeioex@nginx.com> | 2025-02-19 17:36:46 -0800 |
---|---|---|
committer | Dmitry Volyntsev <xeioexception@gmail.com> | 2025-02-20 10:17:00 -0800 |
commit | 1b451958979d38dc162cfa2872197fcba9381f7d (patch) | |
tree | 08dbbfdf95da2a34daa5eefb6766cc0545ace9d6 /nginx/ngx_stream_js_module.c | |
parent | 13f0787fc52e36ae5ed67add0a14c412b3c7b716 (diff) | |
download | njs-1b451958979d38dc162cfa2872197fcba9381f7d.tar.gz njs-1b451958979d38dc162cfa2872197fcba9381f7d.zip |
QuickJS: fixed memory leak in js_periodic handler.
Diffstat (limited to 'nginx/ngx_stream_js_module.c')
-rw-r--r-- | nginx/ngx_stream_js_module.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/nginx/ngx_stream_js_module.c b/nginx/ngx_stream_js_module.c index 59a3e9d2..db00b922 100644 --- a/nginx/ngx_stream_js_module.c +++ b/nginx/ngx_stream_js_module.c @@ -191,6 +191,7 @@ static ngx_stream_session_t *ngx_stream_qjs_session(JSValueConst val); static JSValue ngx_stream_qjs_session_make(JSContext *cx, ngx_int_t proto_id, ngx_stream_session_t *s); static void ngx_stream_qjs_session_finalizer(JSRuntime *rt, JSValue val); +static void ngx_stream_qjs_periodic_finalizer(JSRuntime *rt, JSValue val); #endif @@ -813,7 +814,7 @@ static JSClassDef ngx_stream_qjs_session_class = { static JSClassDef ngx_stream_qjs_periodic_class = { "Periodic", - .finalizer = NULL, + .finalizer = ngx_stream_qjs_periodic_finalizer, }; @@ -2812,6 +2813,20 @@ ngx_stream_qjs_session_finalizer(JSRuntime *rt, JSValue val) } +static void +ngx_stream_qjs_periodic_finalizer(JSRuntime *rt, JSValue val) +{ + ngx_stream_qjs_session_t *ses; + + ses = JS_GetOpaque(val, NGX_QJS_CLASS_ID_STREAM_PERIODIC); + if (ses == NULL) { + return; + } + + js_free_rt(rt, ses); +} + + 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) |