From 947ab0dcd2bc3840da5db789862a75510c48106f Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sun, 18 Mar 2007 20:19:13 +0000 Subject: Ensure content structures are zero initialised. Make css_destroy check that the stylesheet pointer exists (content destructors may be called whilst the content is still loading - e.g. if the content type isn't permissable in the context it was loaded from). Fixes 1627413, 1580980. svn path=/trunk/netsurf/; revision=3212 --- css/css.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'css') diff --git a/css/css.c b/css/css.c index 589f0cc78..aeec73333 100644 --- a/css/css.c +++ b/css/css.c @@ -470,13 +470,16 @@ void css_destroy(struct content *c) unsigned int i; struct css_selector *r; - for (i = 0; i != HASH_SIZE; i++) { - for (r = c->data.css.css->rule[i]; r != 0; r = r->next) { - css_deep_free_style(r->style); + if (c->data.css.css) { + for (i = 0; i != HASH_SIZE; i++) { + for (r = c->data.css.css->rule[i]; r != 0; + r = r->next) { + css_deep_free_style(r->style); + } + css_free_selector(c->data.css.css->rule[i]); } - css_free_selector(c->data.css.css->rule[i]); + free(c->data.css.css); } - free(c->data.css.css); /* imported stylesheets */ for (i = 0; i != c->data.css.import_count; i++) -- cgit v1.2.3