summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2018-07-29 10:30:31 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2018-07-29 10:30:31 +0100
commit0e2affea305cbf683144c9dbffe79e1560106d2c (patch)
tree59ba4df75616275986efe38d590dd974958bc6ce /test
parent77c5d9f20a3e51b64a065e14449333b7a1e9f00d (diff)
downloadlibdom-0e2affea305cbf683144c9dbffe79e1560106d2c.tar.gz
libdom-0e2affea305cbf683144c9dbffe79e1560106d2c.tar.bz2
Ensure we clean up if load_html fails in the test runner
Diffstat (limited to 'test')
-rw-r--r--test/testutils/load.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/test/testutils/load.c b/test/testutils/load.c
index eba4cb0..ea68fcf 100644
--- a/test/testutils/load.c
+++ b/test/testutils/load.c
@@ -101,7 +101,7 @@ dom_document *load_html(const char *file, bool willBeModified)
int handle;
int readed;
dom_hubbub_error error;
- dom_document *ret;
+ dom_document *ret = NULL;
uint8_t buffer[1024];
dom_hubbub_parser_params params;
@@ -118,6 +118,8 @@ dom_document *load_html(const char *file, bool willBeModified)
error = dom_hubbub_parser_create(&params, &parser, &ret);
if (error != DOM_HUBBUB_OK) {
fprintf(stderr, "Can't create Hubbub Parser\n");
+ if (ret != NULL)
+ dom_node_unref(ret);
return NULL;
}
@@ -125,6 +127,8 @@ dom_document *load_html(const char *file, bool willBeModified)
if (handle == -1) {
dom_hubbub_parser_destroy(parser);
/* fprintf(stderr, "Can't open test input file: %s\n", file); */
+ if (ret != NULL)
+ dom_node_unref(ret);
return NULL;
}
@@ -133,6 +137,8 @@ dom_document *load_html(const char *file, bool willBeModified)
if (error != DOM_HUBBUB_OK) {
dom_hubbub_parser_destroy(parser);
fprintf(stderr, "Parsing errors occur\n");
+ if (ret != NULL)
+ dom_node_unref(ret);
return NULL;
}
@@ -142,6 +148,8 @@ dom_document *load_html(const char *file, bool willBeModified)
if (error != DOM_HUBBUB_OK) {
dom_hubbub_parser_destroy(parser);
fprintf(stderr, "Parsing errors occur\n");
+ if (ret != NULL)
+ dom_node_unref(ret);
return NULL;
}
}
@@ -150,6 +158,8 @@ dom_document *load_html(const char *file, bool willBeModified)
if (error != DOM_HUBBUB_OK) {
dom_hubbub_parser_destroy(parser);
fprintf(stderr, "Parsing error when construct DOM\n");
+ if (ret != NULL)
+ dom_node_unref(ret);
return NULL;
}