[njs] Fixed njs_property_query() while quering symbol keys.
Dmitry Volyntsev
xeioex at nginx.com
Wed Aug 19 12:44:23 UTC 2020
details: https://hg.nginx.org/njs/rev/15ae88d60ca4
branches:
changeset: 1498:15ae88d60ca4
user: Dmitry Volyntsev <xeioex at nginx.com>
date: Wed Aug 19 12:43:23 2020 +0000
description:
Fixed njs_property_query() while quering symbol keys.
Since 37f1f20de909, njs_object_hash_test() requires lhq->key.start
to be NULL to avoid hash collisions.
The field is zeroed by njs_property_query_init(), but the field still
might be non-zero when njs_property_query() is called inside a loop.
The fix is to ensure lhq->key.start == NULL for symbol keys.
This closes #268 issue on Github.
diffstat:
src/njs_value.c | 1 +
src/test/njs_unit_test.c | 4 ++++
2 files changed, 5 insertions(+), 0 deletions(-)
diffs (25 lines):
diff -r c9d18ab3eb85 -r 15ae88d60ca4 src/njs_value.c
--- a/src/njs_value.c Tue Aug 18 16:53:46 2020 +0000
+++ b/src/njs_value.c Wed Aug 19 12:43:23 2020 +0000
@@ -568,6 +568,7 @@ njs_property_query(njs_vm_t *vm, njs_pro
if (njs_is_symbol(key)) {
pq->lhq.key_hash = njs_symbol_key(key);
+ pq->lhq.key.start = NULL;
} else {
njs_string_get(&pq->key, &pq->lhq.key);
diff -r c9d18ab3eb85 -r 15ae88d60ca4 src/test/njs_unit_test.c
--- a/src/test/njs_unit_test.c Tue Aug 18 16:53:46 2020 +0000
+++ b/src/test/njs_unit_test.c Wed Aug 19 12:43:23 2020 +0000
@@ -13151,6 +13151,10 @@ static njs_unit_test_t njs_test[] =
"[m.hasOwnProperty('abs'), delete m.abs, m.abs(-1)]"),
njs_str("true,true,1") },
+ { njs_str("var Q = Object.create({}, {a: {value: 'AAA'}, [Symbol.toStringTag]:{value: 'TAG'}});"
+ "Q[Symbol.toStringTag]"),
+ njs_str("TAG") },
+
{ njs_str("Object.getOwnPropertyDescriptor({a:1}, 'a').value"),
njs_str("1") },
More information about the nginx-devel
mailing list