Skip to content

Commit

Permalink
fix: do not use external string as keys (nodejs#42)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Cheng Zhao committed Jun 26, 2018
1 parent 18aeda2 commit e61694e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tools/js2c.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,10 @@ def ReadMacros(lines):

INITIALIZER = """\
CHECK(target->Set(env->context(),
{key}.ToStringChecked(env->isolate()),
v8::String::NewFromUtf8(env->isolate(),
{key}.data(),
v8::NewStringType::kNormal,
arraysize(raw_{key})).ToLocalChecked(),
{value}.ToStringChecked(env->isolate())).FromJust());
"""

Expand Down

0 comments on commit e61694e

Please sign in to comment.