diff options
author | Fedor Indutny <fedor@indutny.com> | 2016-01-29 03:38:14 -0500 |
---|---|---|
committer | Fedor Indutny <fedor@indutny.com> | 2016-01-29 17:16:20 -0500 |
commit | b4ece1b7ec2208917d7a803d5b416236c61f5d6e (patch) | |
tree | 5d0b543762a5507894ff4005835dd1159a2d0b0c /src | |
parent | 137f53c7b72ff9cb36694d058136344076661f4a (diff) | |
download | node-new-b4ece1b7ec2208917d7a803d5b416236c61f5d6e.tar.gz |
contextify: use offset/length from Uint8Array
Do not blindly take data from underlying `ArrayBuffer`, use
`ByteOffset`/`ByteLength` of `Uint8Array` itself.
Additionally, fix tests that weren't actually properly running because
of V8's internal code cache. The code should be different, otherwise the
cached data won't be used at all.
Fix: #4939
PR-URL: https://github.com/nodejs/node/pull/4947
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'src')
-rw-r--r-- | src/node_contextify.cc | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/node_contextify.cc b/src/node_contextify.cc index 7ca622de43..c2ff517abc 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -518,10 +518,11 @@ class ContextifyScript : public BaseObject { ScriptCompiler::CachedData* cached_data = nullptr; if (!cached_data_buf.IsEmpty()) { - ArrayBuffer::Contents contents = - cached_data_buf.ToLocalChecked()->Buffer()->GetContents(); + Local<Uint8Array> ui8 = cached_data_buf.ToLocalChecked(); + ArrayBuffer::Contents contents = ui8->Buffer()->GetContents(); cached_data = new ScriptCompiler::CachedData( - static_cast<uint8_t*>(contents.Data()), contents.ByteLength()); + static_cast<uint8_t*>(contents.Data()) + ui8->ByteOffset(), + ui8->ByteLength()); } ScriptOrigin origin(filename, lineOffset, columnOffset); |