Permalink
Browse files

create new Buffers zeroed

  • Loading branch information...
1 parent 73318fa commit e07af5979190c828caf598b8c371776e4d95863f @xk committed Nov 29, 2010
Showing with 8 additions and 1 deletion.
  1. +8 −1 src/node_buffer.cc
View
@@ -188,8 +188,15 @@ 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 {
+ size_t n = length_;
+ while (n--) {
+ data_[n]= 0;
+ }
+ }
V8::AdjustAmountOfExternalAllocatedMemory(sizeof(Buffer) + length_);
} else {
data_ = NULL;

0 comments on commit e07af59

Please sign in to comment.