about summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorFabrice Bellard <fabrice@bellard.org>2024-01-06 11:20:20 +0100
committerbptato <nincsnevem662@gmail.com>2024-01-11 18:45:36 +0100
commit2fccab156cfa768fe571527f40c0c9171b25b4cc (patch)
tree952d4cdcb62ec35e70dfd949e471c404d29ca9b5 /lib
parente62b89190faf05bf7e3cb92d8d199e39953a20b5 (diff)
downloadchawan-2fccab156cfa768fe571527f40c0c9171b25b4cc.tar.gz
added a comment for non-initialized warning in Valgrind (github issue #153)
Diffstat (limited to 'lib')
-rw-r--r--lib/quickjs/quickjs.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/quickjs/quickjs.c b/lib/quickjs/quickjs.c
index 40beb2dc..78593161 100644
--- a/lib/quickjs/quickjs.c
+++ b/lib/quickjs/quickjs.c
@@ -8000,6 +8000,16 @@ static JSValue JS_GetPropertyValue(JSContext *ctx, JSValueConst this_obj,
         /* fast path for array access */
         p = JS_VALUE_GET_OBJ(this_obj);
         idx = JS_VALUE_GET_INT(prop);
+        /* Note: this code works even if 'p->u.array.count' is not
+           initialized. There are two cases:
+           - 'p' is an array-like object. 'p->u.array.count' is
+             initialized so the slow_path is taken when the index is
+             out of bounds.
+           - 'p' is not an array-like object. 'p->u.array.count' has
+           any value and potentially not initialized. In all the cases
+           (idx >= len or idx < len) the slow path is taken as
+           expected.
+        */
         len = (uint32_t)p->u.array.count;
         if (unlikely(idx >= len))
             goto slow_path;