diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2019-06-01 13:25:14 +0100 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2019-06-01 13:25:14 +0100 |
commit | 9c32564085de877b9fd98aeddc09812fe9b6efb5 (patch) | |
tree | 35e94348bdd32816d3170d44b311f02216070d46 | |
parent | a6de56583c56e2d438639b58b0ce1eb4b64a941a (diff) | |
download | netsurf-9c32564085de877b9fd98aeddc09812fe9b6efb5.tar.gz netsurf-9c32564085de877b9fd98aeddc09812fe9b6efb5.tar.bz2 |
html_script.c: html_script_exec() reqacquire script ptr
Since executing a script can cause more scripts to be appended
to the script array, and that can cause a reallocation which might
move the script array, reacquire the script pointer after running
the script so that we don't wander off into the reeds.
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
-rw-r--r-- | content/handlers/html/html_script.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/content/handlers/html/html_script.c b/content/handlers/html/html_script.c index 203dc5089..2a72d512e 100644 --- a/content/handlers/html/html_script.c +++ b/content/handlers/html/html_script.c @@ -96,6 +96,11 @@ nserror html_script_exec(html_content *c, bool allow_defer) s->data.handle, &size ); script_handler(c->jscontext, data, size, nsurl_access(hlcache_handle_get_url(s->data.handle))); + /* We have to re-acquire this here since the + * c->scripts array may have been reallocated + * as a result of executing this script. + */ + s = &(c->scripts[i]); s->already_started = true; |