From 05970341946ac3afb60e73ec707e3c2abfb8c129 Mon Sep 17 00:00:00 2001 From: Francis Gulotta Date: Wed, 28 Sep 2016 14:15:06 -0400 Subject: [PATCH] Plug a hole in the linux/unix read function (#945) `this.buffer` is never initialized so if we close the port while reading we'll get an error. This has no tests but doesn't fail any of our current tests. With the streams rewrite this is no longer an issue and instead of testing it fully here I'd rather concentrate on a new implementation of it. --- lib/serialport.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/serialport.js b/lib/serialport.js index b017148..df92a89 100644 --- a/lib/serialport.js +++ b/lib/serialport.js @@ -345,6 +345,9 @@ if (process.platform !== 'win32') { // do not emit events if the stream is paused if (this.paused) { + if (!this.buffer) { + this.buffer = new Buffer(0); + } this.buffer = Buffer.concat([this.buffer, b]); return; }