From d32e31d45e8f0d753af07441cbe52774b477392f Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Sun, 25 Apr 2021 20:12:49 +0200 Subject: [PATCH] handle invalid pty ids in ipc --- app/lib/pty.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/lib/pty.ts b/app/lib/pty.ts index 72efb122..1917695a 100644 --- a/app/lib/pty.ts +++ b/app/lib/pty.ts @@ -117,7 +117,7 @@ export class PTY { } export class PTYManager { - private ptys: Record = {} + private ptys: Record = {} init (app: Application): void { //require('./bufferizedPTY')(nodePTY) // eslint-disable-line @typescript-eslint/no-var-requires @@ -132,23 +132,23 @@ export class PTYManager { }) ipcMain.on('pty:get-pid', (event, id) => { - event.returnValue = this.ptys[id].getPID() + event.returnValue = this.ptys[id]?.getPID() }) ipcMain.on('pty:resize', (_event, id, columns, rows) => { - this.ptys[id].resize(columns, rows) + this.ptys[id]?.resize(columns, rows) }) ipcMain.on('pty:write', (_event, id, data) => { - this.ptys[id].write(Buffer.from(data)) + this.ptys[id]?.write(Buffer.from(data)) }) ipcMain.on('pty:kill', (_event, id, signal) => { - this.ptys[id].kill(signal) + this.ptys[id]?.kill(signal) }) ipcMain.on('pty:ack-data', (_event, id, length) => { - this.ptys[id].ackData(length) + this.ptys[id]?.ackData(length) }) } }