summaryrefslogtreecommitdiff
path: root/src/html/html_document.c
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2012-07-21 20:16:26 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2012-07-21 20:16:26 +0100
commitcc4a5d9ccf3367966a8be9fe0721b0bee0c3a5af (patch)
tree149fafc8af993475a2a6f670fc29c6edc36559ab /src/html/html_document.c
parent9374dc45e2967484f2e689cc3b9e27b997f4dcb1 (diff)
downloadlibdom-cc4a5d9ccf3367966a8be9fe0721b0bee0c3a5af.tar.gz
libdom-cc4a5d9ccf3367966a8be9fe0721b0bee0c3a5af.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.c24
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,