From ded257ddfd0351c20f4354f04277542a0f79914f Mon Sep 17 00:00:00 2001
From: Rob Swindell <rob@synchro.net>
Date: Sun, 3 Jan 2021 17:29:52 -0800
Subject: [PATCH] Address "TypeError: buf is null" reported by Melkor

---
 exec/load/binkp.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/exec/load/binkp.js b/exec/load/binkp.js
index b9503466b4..44deef8719 100644
--- a/exec/load/binkp.js
+++ b/exec/load/binkp.js
@@ -217,7 +217,7 @@ BinkP.prototype.crypt = {
 		var ret = '';
 		var ch;
 
-		for (i=0; i<buf.length; i++) {
+		for (i=0; buf !== null && i<buf.length; i++) {
 			ch = ascii(ascii(buf[i]) ^ this.decrypt_byte(keys));
 			ret += ch;
 			this.update_keys(keys, ch);
@@ -229,7 +229,7 @@ BinkP.prototype.crypt = {
 		var i;
 		var ret = '';
 
-		for (i=0; i<buf.length; i++) {
+		for (i=0; buf !== null && i<buf.length; i++) {
 			t = this.decrypt_byte(keys);
 			this.update_keys(keys, buf[i]);
 			ret += ascii(ascii(buf[i]) ^ t);
-- 
GitLab