summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2009-03-27 15:06:30 +0000
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2009-03-27 15:06:30 +0000
commit60018bbb4d98a7b53cf50c05b7f2d0dc4716ebf4 (patch)
treec25d049822b30245ddf60e878c9a337f95bc3553
parenta68c89f90263fa466b5193f4942424cc88aee46c (diff)
downloadlasso-60018bbb4d98a7b53cf50c05b7f2d0dc4716ebf4.tar.gz
lasso-60018bbb4d98a7b53cf50c05b7f2d0dc4716ebf4.tar.xz
lasso-60018bbb4d98a7b53cf50c05b7f2d0dc4716ebf4.zip
XML: fix memory leaks
* lasso/xml/tools.c: * lasso/xml/xml.c: release xmlDoc, properly steal nodes by using xmlSetTreeDoc(xmlnode, NULL);
-rw-r--r--lasso/xml/tools.c13
-rw-r--r--lasso/xml/xml.c2
2 files changed, 7 insertions, 8 deletions
diff --git a/lasso/xml/tools.c b/lasso/xml/tools.c
index af33702a..6e6e7aba 100644
--- a/lasso/xml/tools.c
+++ b/lasso/xml/tools.c
@@ -363,6 +363,7 @@ lasso_load_certs_from_pem_certs_chain_file(const char* pem_certs_chain_file)
}
g_io_channel_shutdown(gioc, TRUE, NULL);
+ g_io_channel_unref(gioc);
return keys_mngr;
}
@@ -800,16 +801,11 @@ lasso_sign_node(xmlNode *xmlnode, const char *id_attr_name, const char *id_value
return critical_error(LASSO_DS_ERROR_SIGNATURE_FAILED);
}
xmlSecDSigCtxDestroy(dsig_ctx);
- xmlUnlinkNode(xmlnode);
xmlRemoveID(doc, id_attr);
-
- xmlnode->parent = old_parent;
-#if 0
- /* memory leak since we don't free doc but it causes some little memory
- * corruption; probably caused by the direct manipulation of xmlnode
- * parent attribute. */
+ xmlUnlinkNode(xmlnode);
lasso_release_doc(doc);
-#endif
+ xmlnode->parent = old_parent;
+ xmlSetTreeDoc(xmlnode, NULL);
return 0;
}
@@ -1091,6 +1087,7 @@ exit:
lasso_release_signature_context(dsigCtx);
if (free_the_doc) {
xmlUnlinkNode(signed_node);
+ xmlSetTreeDoc(signed_node, NULL);
lasso_release_doc(doc);
}
lasso_release_string(id);
diff --git a/lasso/xml/xml.c b/lasso/xml/xml.c
index 580f1fad..40242be3 100644
--- a/lasso/xml/xml.c
+++ b/lasso/xml/xml.c
@@ -1120,6 +1120,7 @@ lasso_node_impl_get_xmlNode(LassoNode *node, gboolean lasso_dump)
xmlNewNs(xmlnode, ns->href, ns->prefix);
t = g_list_next(t);
}
+ g_list_free(list_ns);
xmlSetNs(xmlnode, xmlnode->nsDef);
@@ -1130,6 +1131,7 @@ lasso_node_impl_get_xmlNode(LassoNode *node, gboolean lasso_dump)
class->node_data->snippets, lasso_dump);
t = g_list_previous(t);
}
+ g_list_free(list_classes);
xmlCleanNs(xmlnode);