Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Create new Buffer(length) zeroed #472

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/node_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,12 @@ void Buffer::Replace(char *data, size_t length,
data_ = data;
} else if (length_) {
data_ = new char[length_];
if (data)
if (data) {
memcpy(data_, data, length_);
}
else {
memset( (void*)(data_), 0, length_);
}
V8::AdjustAmountOfExternalAllocatedMemory(sizeof(Buffer) + length_);
} else {
data_ = NULL;
Expand Down