diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2012-07-21 20:16:26 +0100 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2012-07-21 20:16:26 +0100 |
commit | 967380654ba87462dfb2faeeefbb3ea481fe05a2 (patch) | |
tree | 149fafc8af993475a2a6f670fc29c6edc36559ab /src/html/html_document.c | |
parent | b74f19726fd22dbf6eec5cbe8199f2e455d13ef5 (diff) | |
download | libdom-967380654ba87462dfb2faeeefbb3ea481fe05a2.tar.gz libdom-967380654ba87462dfb2faeeefbb3ea481fe05a2.tar.bz2 |
HTMLDocument: If finalise is hung, don't free us underneath ourselves
Diffstat (limited to 'src/html/html_document.c')
-rw-r--r-- | src/html/html_document.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/html/html_document.c b/src/html/html_document.c index ddb8196..7644fde 100644 --- a/src/html/html_document.c +++ b/src/html/html_document.c @@ -116,15 +116,20 @@ out: } /* Finalise a HTMLDocument */ -void _dom_html_document_finalise(dom_html_document *doc) +bool _dom_html_document_finalise(dom_html_document *doc) { int sidx; - dom_string_unref(doc->cookie); - dom_string_unref(doc->url); - dom_string_unref(doc->domain); - dom_string_unref(doc->referrer); - dom_string_unref(doc->title); + if (doc->cookie != NULL) + dom_string_unref(doc->cookie); + if (doc->url != NULL) + dom_string_unref(doc->url); + if (doc->domain != NULL) + dom_string_unref(doc->domain); + if (doc->referrer != NULL) + dom_string_unref(doc->referrer); + if (doc->title != NULL) + dom_string_unref(doc->title); if (doc->memoised != NULL) { for(sidx = 0; sidx < hds_COUNT; ++sidx) { @@ -136,7 +141,7 @@ void _dom_html_document_finalise(dom_html_document *doc) doc->memoised = NULL; } - _dom_document_finalise(&doc->base); + return _dom_document_finalise(&doc->base); } /* Destroy a HTMLDocument */ @@ -144,9 +149,8 @@ void _dom_html_document_destroy(dom_node_internal *node) { dom_html_document *doc = (dom_html_document *) node; - _dom_html_document_finalise(doc); - - free(doc); + if (_dom_html_document_finalise(doc) == true) + free(doc); } dom_exception _dom_html_document_copy(dom_node_internal *old, |