details:   https://hg.nginx.org/njs/rev/41d0de3ad198
branches:  
changeset: 2256:41d0de3ad198
user:      Dmitry Volyntsev <xei...@nginx.com>
date:      Mon Jan 08 16:40:42 2024 -0800
description:
Improved array enumeration with length 0.

The fix eliminates an arithmetic operation with NULL pointer.

Found by UndefinedBehaviorSanitizer.

diffstat:

 src/njs_object.c |  2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diffs (12 lines):

diff -r ee4d396aa418 -r 41d0de3ad198 src/njs_object.c
--- a/src/njs_object.c  Mon Jan 08 16:40:42 2024 -0800
+++ b/src/njs_object.c  Mon Jan 08 16:40:42 2024 -0800
@@ -591,7 +591,7 @@ njs_object_enumerate_array(njs_vm_t *vm,
     njs_value_t  *p, *start, *end;
     njs_array_t  *entry;
 
-    if (!array->object.fast_array) {
+    if (!array->object.fast_array || array->length == 0) {
         return NJS_OK;
     }
 
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel

Reply via email to