From 30d409114d29f84fb93d59c8bc90ce5409e38e2e Mon Sep 17 00:00:00 2001
From: Rob Swindell <rob@synchro.net>
Date: Thu, 26 Nov 2020 12:28:10 -0800
Subject: [PATCH] Fix bug with Socket.getoption() of byte-sized options

Only observed on Windows, the option value variable (val) was uninitialized so querying byte-sized options using WinSock getsockopt() would leave the MSB of the value as undefined (garbage), resulting in sockinfo.js output like this:
KEEPALIVE = -858993663
instead of this:
KEEPALIVE = 1
---
 src/sbbs3/js_socket.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/sbbs3/js_socket.c b/src/sbbs3/js_socket.c
index 35e451d0fb..eae72e8d77 100644
--- a/src/sbbs3/js_socket.c
+++ b/src/sbbs3/js_socket.c
@@ -1515,8 +1515,8 @@ js_getsockopt(JSContext *cx, uintN argc, jsval *arglist)
 	JSObject *obj=JS_THIS_OBJECT(cx, arglist);
 	jsval *argv=JS_ARGV(cx, arglist);
 	int			opt;
-	int			level;
-	int			val;
+	int			level = 0;
+	int			val = 0;
 	js_socket_private_t*	p;
 	LINGER		linger;
 	void*		vp=&val;
-- 
GitLab