From 134fd4ca3e41eefc547c0858fc5f0149037b12e3 Mon Sep 17 00:00:00 2001 From: Raja Osama Date: Wed, 4 Sep 2019 15:36:30 +0500 Subject: [PATCH] FIX | Crash on no Attendence Record Created a fix for the app crashing when you have no record of attendence. --- zklib/zkattendance.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/zklib/zkattendance.js b/zklib/zkattendance.js index 0f8a63f..2d9e2d9 100644 --- a/zklib/zkattendance.js +++ b/zklib/zkattendance.js @@ -59,12 +59,18 @@ module.exports = class { return; } - total_bytes = reply.readUInt32LE(8) - 4; - total_bytes += 2; - - if (total_bytes <= 0) { + try{ + total_bytes = reply.readUInt32LE(8) - 4; + total_bytes += 2; + + if (total_bytes <= 0) { + + internalCallback(new Error('zero')); + return; + } + }catch(err){ internalCallback(new Error('zero')); - return; + return; } if (reply.length > 16) {