From 4f0a97b3e1c5e1ae45b571ddb1b8a0b78db6ac1e Mon Sep 17 00:00:00 2001 From: genda009 Date: Thu, 1 Aug 2019 21:05:40 +0900 Subject: [PATCH 1/2] Fixed a problem that segmentation fault occurs when ReadWorker baton is overwritten. --- package.json | 6 +++--- src/ftdi_device.cc | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 7fdb1d5..c757945 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ftdi", - "version": "1.2.2", + "version": "1.2.3", "description": "FTDI bindings for Node.js", "main": "index.js", "dependencies": { @@ -22,9 +22,9 @@ "driver", "device" ], - "homepage": "https://github.com/thomaschaaf/node-ftdi", + "homepage": "https://github.com/toyoge009/node-ftdi", "bugs": { - "url": "https://github.com/thomaschaaf/node-ftdi/issues" + "url": "https://github.com/toyoge009/node-ftdi/issues" }, "license": "MIT" } diff --git a/src/ftdi_device.cc b/src/ftdi_device.cc index dd85dcd..0a0ddf6 100644 --- a/src/ftdi_device.cc +++ b/src/ftdi_device.cc @@ -160,7 +160,9 @@ class ReadWorker : public Nan::AsyncWorker { // here, so everything we need for input and output // should go on `this`. void Execute () { - baton = new ReadBaton_t(); + baton = &batonEntity; + baton->length = 0; + baton->data = NULL; status = FtdiDevice::ReadDataAsync(device, baton); } @@ -203,7 +205,7 @@ class ReadWorker : public Nan::AsyncWorker { callback->Call(2, argv); } - if(baton->length != 0) + if(baton->data != NULL) { delete baton->data; baton->length = 0; @@ -221,13 +223,13 @@ class ReadWorker : public Nan::AsyncWorker { AsyncQueueWorkerPersistent(this); } - delete baton; }; private: FT_STATUS status; FtdiDevice* device; ReadBaton_t* baton; + ReadBaton_t batonEntity; }; FT_STATUS FtdiDevice::ReadDataAsync(FtdiDevice* device, ReadBaton_t* baton) From 3e7bcb3c9aa26cf6ea34dc50ec3aad511d7a4350 Mon Sep 17 00:00:00 2001 From: Thomas Schaaf Date: Tue, 20 Aug 2019 23:19:16 +0200 Subject: [PATCH 2/2] Update package.json --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c757945..e8ab537 100644 --- a/package.json +++ b/package.json @@ -22,9 +22,9 @@ "driver", "device" ], - "homepage": "https://github.com/toyoge009/node-ftdi", + "homepage": "https://github.com/thomaschaaf/node-ftdi", "bugs": { - "url": "https://github.com/toyoge009/node-ftdi/issues" + "url": "https://github.com/thomaschaaf/node-ftdi/issues" }, "license": "MIT" }