From 92cc0e61bc9b167d6b375ae640ceb6b2a8572378 Mon Sep 17 00:00:00 2001 From: Dmitry Volyntsev Date: Wed, 13 May 2026 17:41:05 -0700 Subject: [PATCH] Improved error stack frame handling. 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 | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/njs_error.c b/src/njs_error.c index 1b38ad61..7c6c0793 100644 --- a/src/njs_error.c +++ b/src/njs_error.c @@ -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; -- 2.47.3