Welcome! Log In Create A New Profile

Advanced

[njs] Fixed njs_property_query() while quering symbol keys.

Dmitry Volyntsev
August 19, 2020 08:46AM
details: https://hg.nginx.org/njs/rev/15ae88d60ca4
branches:
changeset: 1498:15ae88d60ca4
user: Dmitry Volyntsev <xeioex@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") },

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Fixed njs_property_query() while quering symbol keys.

Dmitry Volyntsev 288 August 19, 2020 08:46AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 199
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready