diff options
author | Vincent Sanders <vince@kyllikki.org> | 2015-03-09 13:47:12 +0000 |
---|---|---|
committer | Vincent Sanders <vince@kyllikki.org> | 2015-03-09 13:47:12 +0000 |
commit | 84c29f1d8628fd77de72269b0f424d402fa59a47 (patch) | |
tree | 9ff54f5e665ad026fe6ab5dc562ad145d8e62e3e /render/html_script.c | |
parent | c4e551cd0cecf4ec9aba2d033cba3ca97e669463 (diff) | |
download | netsurf-84c29f1d8628fd77de72269b0f424d402fa59a47.tar.gz netsurf-84c29f1d8628fd77de72269b0f424d402fa59a47.tar.bz2 |
Add invalidate API to html content script handling and use it.
The html content script handling needs to invalidate its JavaScript
context when the browsing context (browser_window) containing it is
either closed or the content fetch is aborted (stopped)
Previously the invalidation was only done on browser_window close
which resulted in use after free crashes because of the now invalid
JavaScript context.
Diffstat (limited to 'render/html_script.c')
-rw-r--r-- | render/html_script.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/render/html_script.c b/render/html_script.c index 4a82bcd70..2ebdffc12 100644 --- a/render/html_script.c +++ b/render/html_script.c @@ -50,20 +50,16 @@ static script_handler_t *select_script_handler(content_type ctype) } -/* attempt defer and async script execution - * - * execute scripts using algorithm found in: - * http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#the-script-element - * - */ -bool html_scripts_exec(html_content *c) +/* exported internal interface documented in render/html_internal.h */ +nserror html_script_exec(html_content *c) { unsigned int i; struct html_script *s; script_handler_t *script_handler; - if (c->jscontext == NULL) - return false; + if (c->jscontext == NULL) { + return NSERROR_BAD_PARAMETER; + } for (i = 0, s = c->scripts; i != c->scripts_count; i++, s++) { if (s->already_started) { @@ -102,7 +98,7 @@ bool html_scripts_exec(html_content *c) } } - return true; + return NSERROR_OK; } /* create new html script entry */ @@ -555,7 +551,8 @@ html_process_script(void *ctx, dom_node *node) return err; } -void html_free_scripts(html_content *html) +/* exported internal interface documented in render/html_internal.h */ +nserror html_script_free(html_content *html) { unsigned int i; @@ -577,4 +574,13 @@ void html_free_scripts(html_content *html) } } free(html->scripts); + + return NSERROR_OK; +} + +/* exported internal interface documented in render/html_internal.h */ +nserror html_script_invalidate_ctx(html_content *htmlc) +{ + htmlc->jscontext = NULL; + return NSERROR_OK; } |