Skip to content

Commit e61694e

Browse files
author
Cheng Zhao
authored
fix: do not use external string as keys (nodejs#42)
blink can not recognize external strings from Node, and it will crash when encountered one, for example executing `window.string_decoder`. Note that the values are still using external strings, but making them normal string may have negative affects on performance, and it is very unlikely they would be passed to blink.
1 parent 18aeda2 commit e61694e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tools/js2c.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,10 @@ def ReadMacros(lines):
232232

233233
INITIALIZER = """\
234234
CHECK(target->Set(env->context(),
235-
{key}.ToStringChecked(env->isolate()),
235+
v8::String::NewFromUtf8(env->isolate(),
236+
{key}.data(),
237+
v8::NewStringType::kNormal,
238+
arraysize(raw_{key})).ToLocalChecked(),
236239
{value}.ToStringChecked(env->isolate())).FromJust());
237240
"""
238241

0 commit comments

Comments
 (0)