]> git.kaiwu.me - njs.git/commitdiff
VM: remove dead code introduced in fd54d52de557
authorDmitry Volyntsev <xeioex@nginx.com>
Sat, 12 Sep 2026 01:45:23 +0000 (18:45 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Mon, 14 Sep 2026 17:53:52 +0000 (10:53 -0700)
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

index 64f5d8a37c2a85dd3825dc8952d51621331daf03..188d85442dda4f58c3830f407f23c41004da57e5 100644 (file)
@@ -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);