Merge pull request #504 from jpilet/master

Fix a memory leak in SerialportPoller::New
This commit is contained in:
Chris Williams 2015-05-07 10:29:06 -04:00
commit deee0285f7

View file

@ -76,18 +76,18 @@ void SerialportPoller::Init(Handle<Object> target) {
NAN_METHOD(SerialportPoller::New) {
NanScope();
SerialportPoller* obj = new SerialportPoller();
if(!args[0]->IsInt32()) {
NanThrowTypeError("First argument must be an fd");
NanReturnUndefined();
}
obj->fd_ = args[0]->ToInt32()->Int32Value();
if(!args[1]->IsFunction()) {
NanThrowTypeError("Third argument must be a function");
NanReturnUndefined();
}
SerialportPoller* obj = new SerialportPoller();
obj->fd_ = args[0]->ToInt32()->Int32Value();
obj->callback_ = new NanCallback(args[1].As<v8::Function>());
// obj->callCallback();