From 2da3eed0601f392a810753b152055f6ddea18111 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sun, 25 Mar 2012 13:21:11 +0000 Subject: Squash scan-build issues svn path=/trunk/libdom/; revision=13686 --- src/core/document.c | 5 +++-- src/core/node.c | 10 ++++++++-- src/core/string.c | 3 +-- src/html/html_collection.c | 6 ++++-- 4 files changed, 16 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/core/document.c b/src/core/document.c index ef2a54e..723d4f8 100644 --- a/src/core/document.c +++ b/src/core/document.c @@ -127,6 +127,8 @@ dom_exception _dom_document_initialise(dom_document *doc, err = _dom_node_initialise(&doc->base, doc, DOM_DOCUMENT_NODE, name, NULL, NULL, NULL); dom_string_unref(name); + if (err != DOM_NO_ERR) + return err; list_init(&doc->pending_nodes); @@ -963,10 +965,9 @@ dom_exception _dom_document_adopt_node(dom_document *doc, *result = NULL; return err; } + dom_node_unref(tmp); } - dom_node_unref(tmp); - return DOM_NO_ERR; } diff --git a/src/core/node.c b/src/core/node.c index 1bd7630..4509f10 100644 --- a/src/core/node.c +++ b/src/core/node.c @@ -720,7 +720,9 @@ dom_exception _dom_node_insert_before(dom_node_internal *node, { dom_exception err; dom_node_internal *n; - + + assert(node != NULL); + /* Ensure that new_child and node are owned by the same document */ if ((new_child->type == DOM_DOCUMENT_TYPE_NODE && new_child->owner != NULL && @@ -736,7 +738,7 @@ dom_exception _dom_node_insert_before(dom_node_internal *node, /* Ensure that ref_child (if any) is a child of node */ if (ref_child != NULL && ref_child->parent != node) return DOM_NOT_FOUND_ERR; - + /* Ensure that new_child is not an ancestor of node, nor node itself */ for (n = node; n != NULL; n = n->parent) { if (n == new_child) @@ -2428,6 +2430,10 @@ dom_exception _dom_node_dispatch_event(dom_event_target *et, evt->current = et; err = _dom_event_target_dispatch(et, &((dom_node_internal *) et)->eti, evt, DOM_AT_TARGET, success); + if (err != DOM_NO_ERR) { + ret = err; + goto cleanup; + } if (evt->stop_now == true || evt->stop == true) goto cleanup; diff --git a/src/core/string.c b/src/core/string.c index 0c82d4e..258b06e 100644 --- a/src/core/string.c +++ b/src/core/string.c @@ -440,7 +440,7 @@ uint32_t dom_string_index(dom_string *str, uint32_t chr) uint32_t dom_string_rindex(dom_string *str, uint32_t chr) { const uint8_t *s; - size_t clen, slen; + size_t clen = 0, slen; uint32_t c, coff, index; parserutils_error err; @@ -686,7 +686,6 @@ dom_exception dom_string_insert(dom_string *target, /* Calculate the byte index of the insertion point */ if (offset == clen) { /* Optimisation for append */ - offset = 0; ins = tlen; } else { while (offset > 0) { diff --git a/src/html/html_collection.c b/src/html/html_collection.c index ec96e66..7532742 100644 --- a/src/html/html_collection.c +++ b/src/html/html_collection.c @@ -209,8 +209,10 @@ dom_exception dom_html_collection_named_item(dom_html_collection *col, { struct dom_node_internal *n = col->root; dom_exception err; - - while (node != NULL) { + + while (*node != NULL) { + assert(n != NULL); + if (n->type == DOM_ELEMENT_NODE && col->ic(n) == true) { dom_string *id = NULL; -- cgit v1.2.3