From 668f6d246d05910b0b0e8a24c91c77d39e059ca7 Mon Sep 17 00:00:00 2001 From: "John \"Elwin\" Edwards" Date: Mon, 6 Jan 2014 09:11:35 -0500 Subject: [PATCH] Check that the ttyrec stream has an fd before passing it to fstat. The stream might not have an fd, presumably if the open isn't complete. Calling fstat then causes crashes. --- rlgwebd.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rlgwebd.js b/rlgwebd.js index 9071688..d4ca770 100755 --- a/rlgwebd.js +++ b/rlgwebd.js @@ -1035,8 +1035,10 @@ function getStatus(callback) { } } for (var i = 0; i < statusinfo.g.length; i++) { - if (statusinfo.g[i].n in sessions) { - fs.fstat(sessions[statusinfo.g[i].n].record.fd, makecallback(i)); + /* fd sometimes isn't a number, presumably when the file isn't open yet. */ + var ssid = statusinfo.g[i].n; + if (ssid in sessions && typeof(sessions[ssid].record.fd) == 'number') { + fs.fstat(sessions[ssid].record.fd, makecallback(i)); } else { idleset(i, null);