From b668b27356f8c6b14cc93f186bd1fbb69af3b072 Mon Sep 17 00:00:00 2001 From: Dmitry Volyntsev Date: Mon, 8 Jan 2024 16:40:42 -0800 Subject: [PATCH] Improved array enumeration with length 0. The fix eliminates an arithmetic operation with NULL pointer. Found by UndefinedBehaviorSanitizer. --- src/njs_object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/njs_object.c b/src/njs_object.c index 4fab06e7..e8901958 100644 --- a/src/njs_object.c +++ b/src/njs_object.c @@ -591,7 +591,7 @@ njs_object_enumerate_array(njs_vm_t *vm, const njs_array_t *array, 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; } -- 2.47.3