aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2023-08-17 10:45:56 +0200
committerSimon Ser <contact@emersion.fr>2023-08-17 10:45:56 +0200
commit8f29f0c35df724a5b07986bcf6168294aadd2785 (patch)
tree56ebcc4eb17ba946faf9cb315bf42dbc8a529036
parent3b383308d43696b827688461da2504372a1fd7ee (diff)
downloadgamja-8f29f0c35df724a5b07986bcf6168294aadd2785.tar.gz
gamja-8f29f0c35df724a5b07986bcf6168294aadd2785.zip
lib/client: ensure server prefix is never null
Fixes a null deref in handleChatMessage, because incoming message prefixes are populated with the server's if null.
-rw-r--r--lib/client.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/client.js b/lib/client.js
index 383af81..a1a969a 100644
--- a/lib/client.js
+++ b/lib/client.js
@@ -49,6 +49,8 @@ const WHOX_FIELDS = {
"realname": "r",
};
+const FALLBACK_SERVER_PREFIX = { name: "*" };
+
let lastLabel = 0;
let lastWhoxToken = 0;
@@ -108,7 +110,7 @@ export default class Client extends EventTarget {
};
status = Client.Status.DISCONNECTED;
- serverPrefix = { name: "*" };
+ serverPrefix = FALLBACK_SERVER_PREFIX;
nick = null;
supportsCap = false;
caps = new irc.CapRegistry();
@@ -190,7 +192,7 @@ export default class Client extends EventTarget {
this.ws = null;
this.setStatus(Client.Status.DISCONNECTED);
this.nick = null;
- this.serverPrefix = null;
+ this.serverPrefix = FALLBACK_SERVER_PREFIX;
this.caps = new irc.CapRegistry();
this.batches = new Map();
Object.keys(this.pendingCmds).forEach((k) => {