[njs] Fixed static analyzer issues.

Vadim Zhestikov v.zhestikov at f5.com
Wed Oct 26 23:35:25 UTC 2022


details:   https://hg.nginx.org/njs/rev/4f66a66ef300
branches:  
changeset: 1987:4f66a66ef300
user:      Vadim Zhestikov <v.zhestikov at f5.com>
date:      Wed Oct 26 16:33:15 2022 -0700
description:
Fixed static analyzer issues.

diffstat:

 src/njs_builtin.c     |  5 +++++
 src/njs_object.c      |  4 ++--
 src/njs_object_prop.c |  2 +-
 src/njs_value.c       |  4 ++--
 src/njs_vmcode.c      |  4 ----
 5 files changed, 10 insertions(+), 9 deletions(-)

diffs (90 lines):

diff -r 109e6cb4dea5 -r 4f66a66ef300 src/njs_builtin.c
--- a/src/njs_builtin.c	Tue Oct 25 09:19:32 2022 -0700
+++ b/src/njs_builtin.c	Wed Oct 26 16:33:15 2022 -0700
@@ -390,6 +390,11 @@ njs_builtin_traverse(njs_vm_t *vm, njs_t
         }
     }
 
+    if (traverse == NULL) {
+        njs_type_error(vm, "njs_builtin_traverse() traverse arg is NULL");
+        return NJS_ERROR;
+    }
+
     n = 0;
 
     while (traverse != NULL) {
diff -r 109e6cb4dea5 -r 4f66a66ef300 src/njs_object.c
--- a/src/njs_object.c	Tue Oct 25 09:19:32 2022 -0700
+++ b/src/njs_object.c	Wed Oct 26 16:33:15 2022 -0700
@@ -2372,7 +2372,7 @@ njs_object_prototype_has_own_property(nj
 
     case NJS_ERROR:
     default:
-        return ret;
+        return NJS_ERROR;
     }
 }
 
@@ -2420,7 +2420,7 @@ njs_object_prototype_prop_is_enumerable(
 
     case NJS_ERROR:
     default:
-        return ret;
+        return NJS_ERROR;
     }
 
     vm->retval = *retval;
diff -r 109e6cb4dea5 -r 4f66a66ef300 src/njs_object_prop.c
--- a/src/njs_object_prop.c	Tue Oct 25 09:19:32 2022 -0700
+++ b/src/njs_object_prop.c	Wed Oct 26 16:33:15 2022 -0700
@@ -842,7 +842,7 @@ njs_object_prop_descriptor(njs_vm_t *vm,
 
     case NJS_ERROR:
     default:
-        return ret;
+        return NJS_ERROR;
     }
 
     desc = njs_object_alloc(vm);
diff -r 109e6cb4dea5 -r 4f66a66ef300 src/njs_value.c
--- a/src/njs_value.c	Tue Oct 25 09:19:32 2022 -0700
+++ b/src/njs_value.c	Wed Oct 26 16:33:15 2022 -0700
@@ -1108,7 +1108,7 @@ slow_path:
     case NJS_ERROR:
     default:
 
-        return ret;
+        return NJS_ERROR;
     }
 
     return NJS_OK;
@@ -1282,7 +1282,7 @@ slow_path:
     case NJS_ERROR:
     default:
 
-        return ret;
+        return NJS_ERROR;
     }
 
     if (njs_slow_path(!njs_object(value)->extensible)) {
diff -r 109e6cb4dea5 -r 4f66a66ef300 src/njs_vmcode.c
--- a/src/njs_vmcode.c	Tue Oct 25 09:19:32 2022 -0700
+++ b/src/njs_vmcode.c	Wed Oct 26 16:33:15 2022 -0700
@@ -103,7 +103,6 @@ njs_vmcode_interpreter(njs_vm_t *vm, u_c
     njs_native_frame_t           *previous, *native;
     njs_property_next_t          *next;
     njs_vmcode_import_t          *import;
-    njs_vmcode_finally_t         *finally;
     njs_vmcode_generic_t         *vmcode;
     njs_vmcode_variable_t        *var;
     njs_vmcode_prop_get_t        *get;
@@ -1722,9 +1721,6 @@ NEXT_LBL;
 
         value2 = (njs_value_t *) vmcode->operand1;
 
-        finally = (njs_vmcode_finally_t *) pc;
-        value1 = njs_scope_value(vm, finally->exit_value);
-
         ret = njs_vmcode_finally(vm, NULL, value2, pc);
 
         switch (ret) {



More information about the nginx-devel mailing list