diff --git a/src/sbbs3/sbbs.h b/src/sbbs3/sbbs.h
index 0d24379ba9818bb35a58b3b8f4240bbd71c7b40c..febbf159583610c2e78bbcf5fb86fce5a5aa4692 100644
--- a/src/sbbs3/sbbs.h
+++ b/src/sbbs3/sbbs.h
@@ -128,15 +128,24 @@ extern int	thread_suid_broken;			/* NPTL is no longer broken */
 	size_t			pos; \
 	const jschar	*val; \
 \
-	if((val=JS_GetStringCharsAndLength(cx, str, &len))) { \
-		if((ret=alloca(len+1))) { \
-			for(pos=0; pos<len; pos++) \
-				ret[pos]=val[pos]; \
-			ret[len]=0; \
+	ret=NULL; \
+	if(str != NULL) { \
+		if((val=JS_GetStringCharsAndLength(cx, str, &len))) { \
+			if((ret=(char *)alloca(len+1))) { \
+				for(pos=0; pos<len; pos++) \
+					ret[pos]=val[pos]; \
+				ret[len]=0; \
+			} \
 		} \
 	} \
 }
 
+#define JSVALUE_TO_STRING(cx, val, ret) \
+{ \
+	JSString	str=JS_ValueToString(cx, val); \
+	JSSTRING_TO_STRING(cx, str, ret); \
+}
+
 #endif
 
 #ifdef USE_CRYPTLIB