summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederic Peters <fpeters@entrouvert.com>2007-01-07 12:17:30 +0000
committerFrederic Peters <fpeters@entrouvert.com>2007-01-07 12:17:30 +0000
commitb189415e39de9657ced9d7a3d5ed174f6bfc3c3c (patch)
tree5cd96a98cb6fd7c717eb076c4426d40d6c45122d
parent999edbe4f2da4580dea6828f56ccde30aeb87727 (diff)
mitigate memory leak (?)
-rw-r--r--lasso/xml/tools.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/lasso/xml/tools.c b/lasso/xml/tools.c
index 2a3fa2b4..48bfde39 100644
--- a/lasso/xml/tools.c
+++ b/lasso/xml/tools.c
@@ -673,6 +673,7 @@ lasso_sign_node(xmlNode *xmlnode, const char *id_attr_name, const char *id_value
xmlDoc *doc;
xmlNode *sign_tmpl, *old_parent;
xmlSecDSigCtx *dsig_ctx;
+ xmlAttr *id_attr = NULL;
sign_tmpl = NULL;
for (sign_tmpl = xmlnode->children; sign_tmpl; sign_tmpl = sign_tmpl->next) {
@@ -689,11 +690,9 @@ lasso_sign_node(xmlNode *xmlnode, const char *id_attr_name, const char *id_value
xmlnode->parent = NULL;
xmlDocSetRootElement(doc, xmlnode);
xmlSetTreeDoc(sign_tmpl, doc);
- if (id_attr_name) {
- xmlAttr *id_attr = xmlHasProp(xmlnode, (xmlChar*)id_attr_name);
- if (id_value) {
- xmlAddID(NULL, doc, (xmlChar*)id_value, id_attr);
- }
+ if (id_attr_name && id_value) {
+ id_attr = xmlHasProp(xmlnode, (xmlChar*)id_attr_name);
+ xmlAddID(NULL, doc, (xmlChar*)id_value, id_attr);
}
dsig_ctx = xmlSecDSigCtxCreate(NULL);
@@ -717,6 +716,8 @@ lasso_sign_node(xmlNode *xmlnode, const char *id_attr_name, const char *id_value
}
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