mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Bug 1026: Protect callback of elinks.load_uri from GC
This commit is contained in:
parent
b2c387f1f4
commit
079b97d21b
3
NEWS
3
NEWS
@ -16,6 +16,9 @@ generally also includes the bug fixes made in ELinks 0.11.4.GIT.
|
||||
|
||||
Bugs that should be removed from NEWS before the 0.12.0 release:
|
||||
|
||||
* major bug 1026 in user SMJS: Protect the callback of elinks.load_uri
|
||||
from the garbage collector. The elinks.load_uri method was added in
|
||||
ELinks 0.12pre1.
|
||||
* bug 955: Reset buttons no longer run FORM/@onsubmit, and
|
||||
``harmless'' buttons no longer submit the form. ELinks 0.12pre1
|
||||
was the first release that had these bugs.
|
||||
|
@ -20,7 +20,9 @@ struct smjs_load_uri_hop {
|
||||
|
||||
/* SpiderMonkey versions earlier than 1.8 cannot properly call
|
||||
* a closure if given just a JSFunction pointer. They need a
|
||||
* jsval that points to the corresponding JSObject. */
|
||||
* jsval that points to the corresponding JSObject. Besides,
|
||||
* JS_AddNamedRoot is not documented to support JSFunction
|
||||
* pointers. */
|
||||
jsval callback;
|
||||
};
|
||||
|
||||
@ -54,6 +56,7 @@ smjs_loading_callback(struct download *download, void *data)
|
||||
end:
|
||||
if (download->cached)
|
||||
object_unlock(download->cached);
|
||||
JS_RemoveRoot(smjs_ctx, &hop->callback);
|
||||
mem_free(download->data);
|
||||
mem_free(download);
|
||||
|
||||
@ -93,6 +96,13 @@ smjs_load_uri(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv,
|
||||
|
||||
hop->callback = argv[1];
|
||||
hop->ses = smjs_ses;
|
||||
if (!JS_AddNamedRoot(smjs_ctx, &hop->callback,
|
||||
"smjs_load_uri_hop.callback")) {
|
||||
mem_free(hop);
|
||||
mem_free(download);
|
||||
done_uri(uri);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
download->data = hop;
|
||||
download->callback = (download_callback_T *) smjs_loading_callback;
|
||||
|
Loading…
Reference in New Issue
Block a user