Skip to content
Commits on Source (2)
......@@ -763,6 +763,7 @@ int js_handle_event(struct mwevent *ev)
unsigned len;
unsigned i;
duk_require_stack(ctx, 5);
if (!duk_get_global_string(ctx, "mw")) {
fprintf(stderr, "mwjs error: failed to lookup mw namespace\n");
return -1;
......@@ -968,6 +969,15 @@ static void define_api(void)
duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_VALUE);
}
static void fatal_handler(void *unused, const char *msg) {
if (msg == NULL)
fprintf(stderr, "mwjs encountered a fatal error - aborting.\n");
else
fprintf(stderr, "mwjs error (fatal): %s\n", msg);
fflush(stderr);
abort();
}
int setup_js(void)
{
int is_local = 1;
......@@ -975,7 +985,7 @@ int setup_js(void)
if (getmylogin() == NULL)
is_local = 0;
ctx = duk_create_heap_default();
ctx = duk_create_heap(NULL, NULL, NULL, NULL, fatal_handler);
if (ctx == NULL)
return -1;
......