mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
[spidermonkey] check for deleted interpreters in document event handler
This commit is contained in:
parent
bb2124bef6
commit
5b6b488e4a
@ -84,6 +84,8 @@
|
||||
|
||||
static int js_module_init_ok;
|
||||
|
||||
std::map<void *, bool> interps;
|
||||
|
||||
static void
|
||||
error_reporter(JSContext *ctx, JSErrorReport *report)
|
||||
{
|
||||
@ -267,6 +269,7 @@ spidermonkey_get_interpreter(struct ecmascript_interpreter *interpreter)
|
||||
if (!ctx) {
|
||||
return nullptr;
|
||||
}
|
||||
interps[(void *)interpreter] = true;
|
||||
|
||||
interpreter->backend_data = ctx;
|
||||
struct view_state *vs = interpreter->vs;
|
||||
@ -528,6 +531,8 @@ spidermonkey_put_interpreter(struct ecmascript_interpreter *interpreter)
|
||||
interpreter->ac = nullptr;
|
||||
interpreter->ar = nullptr;
|
||||
done_heartbeat(interpreter->heartbeat);
|
||||
|
||||
interps.erase((void *)interpreter);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define EL__JS_SPIDERMONKEY_H
|
||||
|
||||
#include <jsapi.h>
|
||||
#include <map>
|
||||
|
||||
struct ecmascript_interpreter;
|
||||
struct form_view;
|
||||
@ -22,4 +23,7 @@ int spidermonkey_eval_boolback(struct ecmascript_interpreter *interpreter, struc
|
||||
void spidermonkey_call_function(struct ecmascript_interpreter *interpreter, JS::HandleValue fun, struct string *ret);
|
||||
|
||||
extern struct module spidermonkey_module;
|
||||
|
||||
extern std::map<void *, bool> interps;
|
||||
|
||||
#endif
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "js/ecmascript.h"
|
||||
#include "js/ecmascript-c.h"
|
||||
#include "js/libdom/parse.h"
|
||||
#include "js/spidermonkey.h"
|
||||
#include "js/spidermonkey/collection.h"
|
||||
#include "js/spidermonkey/form.h"
|
||||
#include "js/spidermonkey/forms.h"
|
||||
@ -1742,6 +1743,11 @@ document_event_handler(dom_event *event, void *pw)
|
||||
#endif
|
||||
struct document_private *doc_private = (struct document_private *)pw;
|
||||
struct ecmascript_interpreter *interpreter = (struct ecmascript_interpreter *)doc_private->interpreter;
|
||||
|
||||
if (interps.find((void *)interpreter) == interps.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
JSContext *ctx = (JSContext *)interpreter->backend_data;
|
||||
JSAutoRealm ar(ctx, (JSObject *)interpreter->ac->get());
|
||||
JS::RootedValue r_val(ctx);
|
||||
|
Loading…
Reference in New Issue
Block a user