From cb07cee0bbba4d0612e1a44e0ab8f0e6c6b5e890 Mon Sep 17 00:00:00 2001 From: Dmitry Volyntsev Date: Fri, 11 Sep 2026 18:45:23 -0700 Subject: [PATCH] VM: remove dead code introduced in fd54d52de557 The lambda structure is allocated at the end of module compilation, and if the allocation fails, lambda is NULL. Since nothing fails after a successful allocation, lambda is always NULL on the failed path. Found by Coverity (CID 1701143). --- src/njs_vm.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/njs_vm.c b/src/njs_vm.c index 64f5d8a3..188d8544 100644 --- a/src/njs_vm.c +++ b/src/njs_vm.c @@ -335,7 +335,6 @@ njs_vm_compile_module(njs_vm_t *vm, njs_str_t *name, u_char **start, njs_function_lambda_t *lambda; parser.mem_pool = NULL; - lambda = NULL; code_index = (vm->codes != NULL) ? vm->codes->items : 0; module = njs_module_find(vm, name, 1); @@ -376,7 +375,7 @@ njs_vm_compile_module(njs_vm_t *vm, njs_str_t *name, u_char **start, } lambda = njs_mp_zalloc(vm->mem_pool, sizeof(njs_function_lambda_t)); - if (njs_fast_path(lambda == NULL)) { + if (njs_slow_path(lambda == NULL)) { njs_memory_error(vm); goto failed; } @@ -398,10 +397,6 @@ failed: njs_parser_destroy(&parser); } - if (lambda != NULL) { - njs_mp_free(vm->mem_pool, lambda); - } - njs_generator_cleanup(vm, code_index); njs_module_remove(vm, module); -- 2.47.3