Skip to content
Snippets Groups Projects
Commit 783f1048 authored by rswindell's avatar rswindell
Browse files

Probably bugfix (segfault while defined "field_list" header object property):

implicitly "root" the property before populating the array. Without this fix,
a GC could free the array while it's being populated.
parent 4a7c170e
No related branches found
No related tags found
No related merge requests found
......@@ -889,6 +889,8 @@ js_get_msg_header(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *
/* Create hdr.field_list[] with repeating header fields (including type and data) */
if((array=JS_NewArrayObject(cx,0,NULL))!=NULL) {
JS_DefineProperty(cx,hdrobj,"field_list",OBJECT_TO_JSVAL(array)
,NULL,NULL,JSPROP_READONLY|JSPROP_ENUMERATE);
items=0;
for(i=0;i<msg.total_hfields;i++) {
switch(msg.hfield[i].type) {
......@@ -928,8 +930,6 @@ js_get_msg_header(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *
,NULL,NULL,JSPROP_ENUMERATE);
items++;
}
JS_DefineProperty(cx,hdrobj,"field_list",OBJECT_TO_JSVAL(array)
,NULL,NULL,JSPROP_READONLY|JSPROP_ENUMERATE);
}
smb_freemsgmem(&msg);
......
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