Skip to content

Commit

Permalink
Merge pull request grpc#3341 from murgatroid99/node_memory_leak_0_11
Browse files Browse the repository at this point in the history
Fixed a couple of memory leaks in Node library
  • Loading branch information
tbetbetbe committed Sep 17, 2015
2 parents 3c142b8 + 640325e commit 1965810
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/node/ext/byte_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Handle<Value> ByteBufferToBuffer(grpc_byte_buffer *buffer) {
memcpy(result + offset, GPR_SLICE_START_PTR(next), GPR_SLICE_LENGTH(next));
offset += GPR_SLICE_LENGTH(next);
}
return NanEscapeScope(MakeFastBuffer(NanNewBufferHandle(result, length)));
return NanEscapeScope(MakeFastBuffer(NanBufferUse(result, length)));
}

Handle<Value> MakeFastBuffer(Handle<Value> slowBuffer) {
Expand Down
5 changes: 4 additions & 1 deletion src/node/ext/call.cc
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ Handle<Value> Op::GetOpType() const {
return NanEscapeScope(NanNew<String>(GetTypeString()));
}

Op::~Op() {
}

class SendMetadataOp : public Op {
public:
Handle<Value> GetNodeValue() const {
Expand Down Expand Up @@ -325,7 +328,7 @@ class ReadMessageOp : public Op {
}
~ReadMessageOp() {
if (recv_message != NULL) {
gpr_free(recv_message);
grpc_byte_buffer_destroy(recv_message);
}
}
Handle<Value> GetNodeValue() const {
Expand Down
2 changes: 1 addition & 1 deletion src/node/ext/call.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ struct Resources {

class Op {
public:
virtual ~Op();
virtual v8::Handle<v8::Value> GetNodeValue() const = 0;
virtual bool ParseOp(v8::Handle<v8::Value> value, grpc_op *out,
shared_ptr<Resources> resources) = 0;
Expand All @@ -98,7 +99,6 @@ class Op {
};

typedef std::vector<unique_ptr<Op>> OpVec;

struct tag {
tag(NanCallback *callback, OpVec *ops,
shared_ptr<Resources> resources);
Expand Down

0 comments on commit 1965810

Please sign in to comment.