Skip to content

Commit

Permalink
Merge pull request grpc#5185 from lepatryk/byte-buffer
Browse files Browse the repository at this point in the history
Pass delete[] explicitely to Nan::NewBuffer.
  • Loading branch information
murgatroid99 committed Feb 10, 2016
2 parents 42fad8e + 777777e commit 82e7eff
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/node/ext/byte_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ grpc_byte_buffer *BufferToByteBuffer(Local<Value> buffer) {
return byte_buffer;
}

namespace {
void delete_buffer(char *data, void *hint) { delete[] data; }
}

Local<Value> ByteBufferToBuffer(grpc_byte_buffer *buffer) {
Nan::EscapableHandleScope scope;
if (buffer == NULL) {
Expand All @@ -80,7 +84,7 @@ Local<Value> ByteBufferToBuffer(grpc_byte_buffer *buffer) {
gpr_slice_unref(next);
}
return scope.Escape(MakeFastBuffer(
Nan::NewBuffer(result, length).ToLocalChecked()));
Nan::NewBuffer(result, length, delete_buffer, NULL).ToLocalChecked()));
}

Local<Value> MakeFastBuffer(Local<Value> slowBuffer) {
Expand Down

0 comments on commit 82e7eff

Please sign in to comment.