Skip to content
Snippets Groups Projects
Commit 621d77fb authored by rswindell's avatar rswindell
Browse files

Bug-fix: when enumerating a message header (returned from

MsgBase.get_msg_header or get_all_msg_headers), the message header object's
private data (used internally in these C source functions) would be freed and
NULL'd, apparenty as a form of optimization. This would cause some methods
which can accept a msg header object as an argument (e.g.
MsgBase.put_msg_header, bbs.show_msg/show_msg_header) to fail or behave
in strange ways.

Instead of freeing/NULLing the private data (and depending on that as an
indication that the header has been enuemrated), just set a member variable
indicating that the header has been enumerated (once) already.

This is the bug that has been tripping me up with my message lister JS mod
(see YouTube video). I can finally get that committed to CVS for testing now.
:-)
parent 511cbf5a
No related branches found
No related tags found
No related merge requests found
......@@ -53,6 +53,7 @@ typedef struct
{
private_t *p;
BOOL expand_fields;
BOOL enumerated;
smbmsg_t msg;
post_t post;
......@@ -1352,7 +1353,7 @@ static JSBool js_get_msg_header_resolve(JSContext *cx, JSObject *obj, jsid id)
}
/* If we have already enumerated, we're done here... */
if((p=(privatemsg_t*)JS_GetPrivate(cx,obj))==NULL) {
if((p=(privatemsg_t*)JS_GetPrivate(cx,obj))==NULL || p->enumerated) {
if(name) free(name);
return JS_TRUE;
}
......@@ -1639,10 +1640,7 @@ static JSBool js_get_msg_header_enumerate(JSContext *cx, JSObject *obj)
if((p=(privatemsg_t*)JS_GetPrivate(cx,obj))==NULL)
return JS_TRUE;
smb_freemsgmem(&(p->msg));
free(p);
JS_SetPrivate(cx, obj, NULL);
p->enumerated = TRUE;
return JS_TRUE;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment