summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsangwan.kwon <sangwan.kwon@samsung.com>2016-12-13 05:26:58 (GMT)
committersangwan.kwon <sangwan.kwon@samsung.com>2016-12-13 05:26:58 (GMT)
commit569d8600374c6e0b686443467a148987265668f7 (patch)
tree8fc65f9d93b5ff1c752607330866e34bff9e3d8d
parent3c90aa6afef99bb7af54c7803d7e4ccb815d9d20 (diff)
downloadxmlsec1-569d8600374c6e0b686443467a148987265668f7.zip
xmlsec1-569d8600374c6e0b686443467a148987265668f7.tar.gz
xmlsec1-569d8600374c6e0b686443467a148987265668f7.tar.bz2
Fix memory leak on upstream coderefs/changes/25/104325/1
* The result of xmlGetProp() should be free. * See, http://xmlsoft.org/library.html Change-Id: I42570b24df40606dd0603a7ef4f0a2994089d9f6 Signed-off-by: sangwan.kwon <sangwan.kwon@samsung.com>
-rw-r--r--src/relationship.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/relationship.c b/src/relationship.c
index f301ed7..e510d4b 100644
--- a/src/relationship.c
+++ b/src/relationship.c
@@ -232,6 +232,7 @@ xmlSecRelationshipReadNode(xmlSecTransformPtr transform, xmlNodePtr node, xmlSec
"xmlStrdup",
XMLSEC_ERRORS_R_STRDUP_FAILED,
"len=%d", xmlStrlen(sourceId));
+ xmlFree(sourceId);
return(-1);
}
@@ -242,9 +243,12 @@ xmlSecRelationshipReadNode(xmlSecTransformPtr transform, xmlNodePtr node, xmlSec
"xmlSecPtrListAdd",
XMLSEC_ERRORS_R_XMLSEC_FAILED,
XMLSEC_ERRORS_NO_MESSAGE);
+ xmlFree(sourceId);
xmlFree(tmp);
return(-1);
}
+ xmlFree(sourceId);
+ xmlFree(tmp);
}
cur = cur->next;
@@ -258,6 +262,7 @@ static int
xmlSecTransformRelationshipCompare(xmlNodePtr node1, xmlNodePtr node2) {
xmlChar* id1;
xmlChar* id2;
+ int ret;
if(node1 == node2) {
return(0);
@@ -275,10 +280,15 @@ xmlSecTransformRelationshipCompare(xmlNodePtr node1, xmlNodePtr node2) {
return(-1);
}
if(id2 == NULL) {
+ xmlFree(id1);
return(1);
}
- return(xmlStrcmp(id1, id2));
+ ret = xmlStrcmp(id1, id2);
+ xmlFree(id1);
+ xmlFree(id2);
+
+ return(ret);
}
/**
@@ -316,8 +326,10 @@ xmlSecTransformRelationshipProcessNode(xmlSecTransformPtr transform, xmlOutputBu
}
if(found < 0) {
+ xmlFree(id);
return(0);
}
+ xmlFree(id);
}
ret = xmlSecTransformRelationshipProcessElementNode(transform, buf, cur);
@@ -523,7 +535,7 @@ xmlSecTransformRelationshipProcessElementNode(xmlSecTransformPtr transform, xmlO
* This is step 3, point 6: add default value of TargetMode if there is no such attribute.
*/
for(attr = cur->properties; attr != NULL; attr = attr->next) {
- xmlChar * value = xmlGetProp(cur, attr->name);
+ xmlChar* value = xmlGetProp(cur, attr->name);
if(xmlStrcmp(attr->name, xmlSecRelationshipAttrTargetMode) == 0) {
foundTargetMode = 1;
@@ -536,8 +548,10 @@ xmlSecTransformRelationshipProcessElementNode(xmlSecTransformPtr transform, xmlO
"xmlSecTransformRelationshipWriteProp",
XMLSEC_ERRORS_R_XMLSEC_FAILED,
XMLSEC_ERRORS_NO_MESSAGE);
+ xmlFree(value);
return(-1);
}
+ xmlFree(value);
}
/* write TargetMode */