summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Sanders <vince@netsurf-browser.org>2013-11-08 08:58:36 (GMT)
committer Vincent Sanders <vince@netsurf-browser.org>2013-11-08 08:58:36 (GMT)
commitc7ae36d32805b65a0318e89905261c587751e053 (patch)
treeea2b594a88876f6d7c8ea95aaff89d74d45ecaed
parent955cfb43a942899332b38059cc5c213f210825ca (diff)
downloadlibdom-c7ae36d32805b65a0318e89905261c587751e053.tar.gz
libdom-c7ae36d32805b65a0318e89905261c587751e053.tar.bz2
ensure _dom_element_set_attr_node does not leak on error paths (coverity 1127085)
-rw-r--r--src/core/element.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/core/element.c b/src/core/element.c
index a6ef928..6b3de9e 100644
--- a/src/core/element.c
+++ b/src/core/element.c
@@ -1964,8 +1964,10 @@ dom_exception _dom_element_set_attr_node(struct dom_element *element,
/* TODO: We did not support some node type such as entity reference, in
* that case, we should ignore the error to make sure the event model
* work as excepted. */
- if (err != DOM_NO_ERR && err != DOM_NOT_SUPPORTED_ERR)
+ if (err != DOM_NO_ERR && err != DOM_NOT_SUPPORTED_ERR) {
+ _dom_element_attr_list_node_destroy(match);
return err;
+ }
err = _dom_dispatch_attr_modified_event(doc, e, NULL, new,
(dom_event_target *) attr, name,
DOM_MUTATION_ADDITION, &success);
@@ -1973,19 +1975,24 @@ dom_exception _dom_element_set_attr_node(struct dom_element *element,
dom_string_unref(new);
dom_string_unref(name);
if (err != DOM_NO_ERR) {
+ _dom_element_attr_list_node_destroy(match);
return err;
}
err = dom_node_dispatch_node_change_event(doc, attr, element,
DOM_MUTATION_ADDITION, &success);
- if (err != DOM_NO_ERR)
+ if (err != DOM_NO_ERR) {
+ _dom_element_attr_list_node_destroy(match);
return err;
+ }
success = true;
err = _dom_dispatch_subtree_modified_event(doc,
(dom_event_target *) element, &success);
- if (err != DOM_NO_ERR)
+ if (err != DOM_NO_ERR) {
+ _dom_element_attr_list_node_destroy(match);
return err;
+ }
/* Link into element's attribute list */
if (element->attributes == NULL)