From: Dmitry Volyntsev Date: Sat, 12 Sep 2026 01:45:23 +0000 (-0700) Subject: VM: remove dead code introduced in fd54d52de557 X-Git-Tag: 1.0.2~53 X-Git-Url: https://git.kaiwu.me/?a=commitdiff_plain;h=cb07cee0bbba4d0612e1a44e0ab8f0e6c6b5e890;p=njs.git 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). --- 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);