diff options
| author | Valery Febvre <vfebvre at easter-eggs.com> | 2004-05-15 00:38:03 +0000 |
|---|---|---|
| committer | Valery Febvre <vfebvre at easter-eggs.com> | 2004-05-15 00:38:03 +0000 |
| commit | 98d6264eadc827ff34e1bee2d3643f43567c00d0 (patch) | |
| tree | 7837fbc1b5d9d13a6981fae79f2474638c04948b /lasso/xml | |
| parent | 5ba578ade45dd65238fa7c94b6fff641c67e79ce (diff) | |
| download | lasso-98d6264eadc827ff34e1bee2d3643f43567c00d0.tar.gz lasso-98d6264eadc827ff34e1bee2d3643f43567c00d0.tar.xz lasso-98d6264eadc827ff34e1bee2d3643f43567c00d0.zip | |
Many many memory leaks fixed
Diffstat (limited to 'lasso/xml')
| -rw-r--r-- | lasso/xml/ds_signature.c | 4 | ||||
| -rw-r--r-- | lasso/xml/tools.c | 7 | ||||
| -rw-r--r-- | lasso/xml/xml.c | 40 |
3 files changed, 40 insertions, 11 deletions
diff --git a/lasso/xml/ds_signature.c b/lasso/xml/ds_signature.c index 28a20022..3bc5455d 100644 --- a/lasso/xml/ds_signature.c +++ b/lasso/xml/ds_signature.c @@ -102,8 +102,8 @@ GType lasso_ds_signature_get_type() { /** * lasso_ds_signature_new: - * @doc: the doc - * @signMethodId: the signature method (RsaSha1 or DsaSha1) + * @node: the doc + * @sign_method: the signature method (RsaSha1 or DsaSha1) * * Creates a new <ds:Signature> node object. * diff --git a/lasso/xml/tools.c b/lasso/xml/tools.c index 67712c43..bf1d5da8 100644 --- a/lasso/xml/tools.c +++ b/lasso/xml/tools.c @@ -87,7 +87,7 @@ lasso_get_current_time() { struct tm *tm; GTimeVal time_val; - xmlChar *ret = g_malloc(21); + xmlChar *ret = xmlMalloc(21); g_get_current_time(&time_val); tm = localtime(&(time_val.tv_sec)); @@ -186,6 +186,7 @@ lasso_query_verify_signature(const gchar *query, xmlDocPtr doc; xmlNodePtr sigNode, sigValNode; xmlSecDSigCtxPtr dsigCtx; + xmlChar *str_unescaped; gchar **str_split; /* 0: signature invalid @@ -207,7 +208,9 @@ lasso_query_verify_signature(const gchar *query, xmlSecNodeSignatureValue, xmlSecDSigNs); /* set SignatureValue content */ - xmlNodeSetContent(sigValNode, lasso_str_unescape(str_split[1])); + str_unescaped = lasso_str_unescape(str_split[1]); + xmlNodeSetContent(sigValNode, str_unescaped); + xmlFree(str_unescaped); g_strfreev(str_split); //xmlDocDump(stdout, doc); diff --git a/lasso/xml/xml.c b/lasso/xml/xml.c index 402cd6af..1e82b035 100644 --- a/lasso/xml/xml.c +++ b/lasso/xml/xml.c @@ -29,6 +29,7 @@ struct _LassoNodePrivate { gboolean dispose_has_run; xmlNodePtr node; + GPtrArray *children; }; /*****************************************************************************/ @@ -714,24 +715,39 @@ lasso_node_impl_add_child(LassoNode *node, LassoNode *child, gboolean unbounded) { - LassoNode *old_child; + xmlNodePtr old_child; + LassoNode *search_child = NULL; + gint i; g_return_if_fail (LASSO_IS_NODE(node)); g_return_if_fail (LASSO_IS_NODE(child)); - // if child is not unbounded, we search it + /* if child is not unbounded, we search it */ if (!unbounded) { - old_child = lasso_node_get_child(node, child->private->node->name); + //old_child = lasso_node_get_child(node, child->private->node->name); + old_child = xmlSecFindNode(node->private->node, + child->private->node->name, NULL); } if (!unbounded && old_child != NULL) { - // child replace old child - xmlReplaceNode(old_child->private->node, child->private->node); + /* old child removed in array children and freed */ + for(i=0;i<node->private->children->len;i++) { + search_child = LASSO_NODE(g_ptr_array_index(node->private->children, i)); + if (search_child->private->node == old_child) { + g_ptr_array_remove_index(node->private->children, i); + break; + } + } + /* child replace old child */ + xmlReplaceNode(old_child, child->private->node); + g_object_unref(G_OBJECT(search_child)); } else { - // else child is added + /* else child is added */ xmlAddChild(node->private->node, child->private->node); } + /* child added in children array */ + g_ptr_array_add(node->private->children, (gpointer)child); } static void @@ -1014,7 +1030,16 @@ lasso_node_dispose(LassoNode *node) static void lasso_node_finalize(LassoNode *node) { + gint i; + LassoNode *child; + g_print("%s 0x%x finalized ...\n", lasso_node_get_name(node), node); + for(i=0;i<node->private->children->len;i++) { + child = LASSO_NODE(g_ptr_array_index(node->private->children, i)); + g_ptr_array_remove_index(node->private->children, i); + g_object_unref(G_OBJECT(child)); + } + xmlUnlinkNode(node->private->node); xmlFreeNode(node->private->node); g_free (node->private); } @@ -1030,7 +1055,8 @@ lasso_node_instance_init(LassoNode *instance) node->private = g_new (LassoNodePrivate, 1); node->private->dispose_has_run = FALSE; - node->private->node = xmlNewNode(NULL, "no-name-set"); + node->private->node = xmlNewNode(NULL, "no-name-set"); + node->private->children = g_ptr_array_new(); } static void |
