From 9769e8f2c067b8f5bbebe3bede0ab223dbae357d Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sat, 4 May 2019 16:42:47 +0100 Subject: Clean up async/defer JS contents during parent finalisation Signed-off-by: Daniel Silverstone --- content/handlers/html/html_script.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/content/handlers/html/html_script.c b/content/handlers/html/html_script.c index b404d2edf..6f62fb989 100644 --- a/content/handlers/html/html_script.c +++ b/content/handlers/html/html_script.c @@ -597,16 +597,21 @@ nserror html_script_free(html_content *html) dom_string_unref(html->scripts[i].mimetype); } - if ((html->scripts[i].type == HTML_SCRIPT_INLINE) && - (html->scripts[i].data.string != NULL)) { - - dom_string_unref(html->scripts[i].data.string); - - } else if ((html->scripts[i].type == HTML_SCRIPT_SYNC) && - (html->scripts[i].data.handle != NULL)) { - - hlcache_handle_release(html->scripts[i].data.handle); - + switch (html->scripts[i].type) { + case HTML_SCRIPT_INLINE: + if (html->scripts[i].data.string != NULL) { + dom_string_unref(html->scripts[i].data.string); + } + break; + case HTML_SCRIPT_SYNC: + /* fallthrough */ + case HTML_SCRIPT_ASYNC: + /* fallthrough */ + case HTML_SCRIPT_DEFER: + if (html->scripts[i].data.handle != NULL) { + hlcache_handle_release(html->scripts[i].data.handle); + } + break; } } free(html->scripts); -- cgit v1.2.3