Skip to content
GitLab
Explore
Sign in
Commits on Source (2)
js-duk: Require stack space for js_handle_event()
· b13b7bd8
Andrew Price
authored
Oct 09, 2018
b13b7bd8
js-duk: Install a fatal error handler
· bc7f079f
Andrew Price
authored
Oct 09, 2018
Gives more info than the unexplained aborts that duktape does by default.
bc7f079f
Hide whitespace changes
Inline
Side-by-side
src/client/js-duk.c
View file @
bc7f079f
...
...
@@ -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
;
...
...