mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
buffer: properly apply dst offset and src length on fast path
Refs: https://github.com/nodejs/node/pull/54311#issuecomment-2290453437 PR-URL: https://github.com/nodejs/node/pull/54391 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
This commit is contained in:
parent
05495909d7
commit
2c1461541f
@ -1479,11 +1479,12 @@ uint32_t FastWriteString(Local<Value> receiver,
|
||||
CHECK(offset <= dst.length());
|
||||
CHECK(dst.length() - offset <= std::numeric_limits<uint32_t>::max());
|
||||
|
||||
max_length = std::min<uint32_t>(dst.length() - offset, max_length);
|
||||
const auto size = std::min(
|
||||
{static_cast<uint32_t>(dst.length() - offset), max_length, src.length});
|
||||
|
||||
memcpy(dst_data, src.data, max_length);
|
||||
memcpy(dst_data + offset, src.data, size);
|
||||
|
||||
return max_length;
|
||||
return size;
|
||||
}
|
||||
|
||||
static v8::CFunction fast_write_string(v8::CFunction::Make(FastWriteString));
|
||||
|
Loading…
Reference in New Issue
Block a user