mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Rework smjs_load_hooks not to free path until it is done and to always
call done_string on the script string, even when add_file_to_string fails.
This commit is contained in:
parent
7b6afb52c8
commit
5ca5381fbc
@ -71,7 +71,6 @@ void
|
||||
smjs_load_hooks(void)
|
||||
{
|
||||
jsval rval;
|
||||
struct string *string;
|
||||
struct string script;
|
||||
unsigned char *path;
|
||||
|
||||
@ -83,15 +82,13 @@ smjs_load_hooks(void)
|
||||
path = stracpy(CONFDIR "/" SMJS_HOOKS_FILENAME);
|
||||
}
|
||||
|
||||
string = add_file_to_string(&script, path);
|
||||
mem_free(path);
|
||||
if (!string) return;
|
||||
|
||||
if (JS_FALSE == JS_EvaluateScript(smjs_ctx,
|
||||
if (add_file_to_string(&script, path)
|
||||
&& JS_FALSE == JS_EvaluateScript(smjs_ctx,
|
||||
JS_GetGlobalObject(smjs_ctx),
|
||||
script.source, script.length, path, 1, &rval))
|
||||
alert_smjs_error("error loading default script file");
|
||||
|
||||
mem_free(path);
|
||||
done_string(&script);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user