Skip to content

Commit 249b76c

Browse files
committed
Modules: fixed memory leak when module loading failed.
1 parent 9f4a02c commit 249b76c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

nginx/ngx_js.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,7 @@ ngx_engine_njs_init(ngx_engine_t *engine, ngx_engine_opts_t *opts)
571571

572572
rc = ngx_js_set_cwd(njs_vm_memory_pool(vm), opts->conf, &vm_options.file);
573573
if (rc != NGX_OK) {
574+
njs_vm_destroy(vm);
574575
return NGX_ERROR;
575576
}
576577

@@ -665,6 +666,7 @@ ngx_njs_clone(ngx_js_ctx_t *ctx, ngx_js_loc_conf_t *cf, void *external)
665666

666667
engine = njs_mp_alloc(njs_vm_memory_pool(vm), sizeof(ngx_engine_t));
667668
if (engine == NULL) {
669+
njs_vm_destroy(vm);
668670
return NULL;
669671
}
670672

@@ -677,6 +679,8 @@ ngx_njs_clone(ngx_js_ctx_t *ctx, ngx_js_loc_conf_t *cf, void *external)
677679

678680
ngx_log_error(NGX_LOG_ERR, ctx->log, 0, "js exception: %V", &exception);
679681

682+
njs_vm_destroy(vm);
683+
680684
return NULL;
681685
}
682686

0 commit comments

Comments
 (0)