From a0a6364e5f278e248022a42185a078003958f9ad Mon Sep 17 00:00:00 2001
From: deuce <>
Date: Tue, 10 Nov 2009 00:07:11 +0000
Subject: [PATCH] Fix user subobject problems resulting from getting the
 iterator for the class prototype...

Solution from
https://developer.mozilla.org/en/SpiderMonkey/JSAPI_Reference/JS_InitClass

Note: By default JS_InitClass creates a prototype object but does not invoke
the constructor (JSClass.construct) on it. However, the prototype object
will eventually be finalized (JSClass.finalize). This inconsistency can
cause problems; for example, if the finalizer calls JS_GetPrivate(),
expecting that the constructor called JS_SetPrivate(), it may find that the
private data is NULL. The JSCLASS_CONSTRUCT_PROTOTYPE flag is one way to
avoid this inconsistency.
---
 src/sbbs3/js_user.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/sbbs3/js_user.c b/src/sbbs3/js_user.c
index 3724e7460c..3677bbcbb3 100644
--- a/src/sbbs3/js_user.c
+++ b/src/sbbs3/js_user.c
@@ -1270,7 +1270,7 @@ static JSBool js_user_enumerate(JSContext *cx, JSObject *obj)
 
 static JSClass js_user_class = {
      "User"					/* name			*/
-    ,JSCLASS_HAS_PRIVATE	/* flags		*/
+    ,JSCLASS_HAS_PRIVATE|JSCLASS_CONSTRUCT_PROTOTYPE	/* flags		*/
 	,JS_PropertyStub		/* addProperty	*/
 	,JS_PropertyStub		/* delProperty	*/
 	,js_user_get			/* getProperty	*/
-- 
GitLab