]> git.kaiwu.me - njs.git/commitdiff
Improved error stack frame handling.
authorDmitry Volyntsev <xeioex@nginx.com>
Thu, 14 May 2026 00:41:05 +0000 (17:41 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Thu, 14 May 2026 16:29:24 +0000 (09:29 -0700)
Native frames always have an associated function.  Keep the function
lookup in the native-frame branch to make the invariant explicit and to
avoid confusing static analysis.

Found by Coverity (CID 1681309).

src/njs_error.c

index 1b38ad617a1d48a78bf88530c420838a8349591f..7c6c0793d7c72ed8937fb7f8f0f0902737b72822 100644 (file)
@@ -101,12 +101,6 @@ njs_error_stack_attach(njs_vm_t *vm, njs_value_t value, njs_uint_t skip)
             continue;
         }
 
-        function = frame->native ? frame->function : NULL;
-
-        if (function != NULL && function->bound != NULL) {
-            continue;
-        }
-
         line = 0;
         file = njs_str_value("");
 
@@ -135,6 +129,13 @@ njs_error_stack_attach(njs_vm_t *vm, njs_value_t value, njs_uint_t skip)
             }
 
         } else {
+            function = frame->function;
+            njs_assert(function != NULL);
+
+            if (njs_slow_path(function->bound != NULL)) {
+                continue;
+            }
+
             name.length = 0;
             fhq.key_hash = NJS_ATOM_STRING_name;