Skip to content

Commit

Permalink
Fixed console.timeEnd() memleak.
Browse files Browse the repository at this point in the history
  • Loading branch information
xeioex committed Sep 11, 2024
1 parent a62eed8 commit ab19fef
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions nginx/ngx_js.c
Original file line number Diff line number Diff line change
Expand Up @@ -1938,6 +1938,10 @@ ngx_qjs_ext_console_time_end(JSContext *cx, JSValueConst this_val, int argc,
ngx_log_error(NGX_LOG_INFO, c->log, 0, "js: %V: %uL.%06uLms",
&name, ms, ns);

if (name.data != default_label.data) {
JS_FreeCString(cx, (char *) name.data);
}

return JS_UNDEFINED;

not_found:
Expand All @@ -1946,6 +1950,10 @@ ngx_qjs_ext_console_time_end(JSContext *cx, JSValueConst this_val, int argc,
ngx_log_error(NGX_LOG_INFO, c->log, 0, "js: Timer \"%V\" doesn't exist",
&name);

if (name.data != default_label.data) {
JS_FreeCString(cx, (char *) name.data);
}

return JS_UNDEFINED;
}

Expand Down

0 comments on commit ab19fef

Please sign in to comment.