Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Check return code in ixml

Check return code of ixmlDocument_CreateElementEx in
ixmlDocument_CreateElement.
Check return code of ixmlNode_setNodeName and ixmlNode_setNodeValue in
ixmlNode_cloneCDATASect and ixmlNode_cloneTextNode.
  • Loading branch information...
commit d3d17da6e5ddb8be5e1085ac653d79e46708169a 1 parent e0444b2
@ffontaine ffontaine authored
Showing with 39 additions and 6 deletions.
  1. +9 −0 ChangeLog
  2. +7 −1 ixml/src/document.c
  3. +23 −5 ixml/src/node.c
View
9 ChangeLog
@@ -4,6 +4,15 @@ Version 1.6.16
2012-03-16 Fabrice Fontaine <fabrice.fontaine(at)orange.com>
+ Check return code in ixml
+
+ Check return code of ixmlDocument_CreateElementEx in
+ ixmlDocument_CreateElement.
+ Check return code of ixmlNode_setNodeName and ixmlNode_setNodeValue in
+ ixmlNode_cloneCDATASect and ixmlNode_cloneTextNode.
+
+2012-03-16 Fabrice Fontaine <fabrice.fontaine(at)orange.com>
+
Add more explicit casts and remove dead code
Comment unused SERVER from DeviceShutdown.
View
8 ixml/src/document.c
@@ -165,8 +165,14 @@ IXML_Element *ixmlDocument_createElement(
const DOMString tagName)
{
IXML_Element *newElement = NULL;
+ int ret = IXML_SUCCESS;
- ixmlDocument_createElementEx(doc, tagName, &newElement);
+ ret = ixmlDocument_createElementEx(doc, tagName, &newElement);
+ if (ret != IXML_SUCCESS) {
+ IxmlPrintf(__FILE__, __LINE__, "ixmlDocument_createElement",
+ "Error %d\n", ret);
+ return NULL;
+ }
return newElement;
}
View
28 ixml/src/node.c
@@ -655,6 +655,7 @@ static IXML_Node *ixmlNode_cloneTextNode(
IXML_Node *nodeptr)
{
IXML_Node *newNode = NULL;
+ int rc;
assert(nodeptr != NULL);
@@ -663,8 +664,16 @@ static IXML_Node *ixmlNode_cloneTextNode(
return NULL;
} else {
ixmlNode_init(newNode);
- ixmlNode_setNodeName(newNode, nodeptr->nodeName);
- ixmlNode_setNodeValue(newNode, nodeptr->nodeValue);
+ rc = ixmlNode_setNodeName(newNode, nodeptr->nodeName);
+ if (rc != IXML_SUCCESS) {
+ ixmlNode_free(newNode);
+ return NULL;
+ }
+ rc = ixmlNode_setNodeValue(newNode, nodeptr->nodeValue);
+ if (rc != IXML_SUCCESS) {
+ ixmlNode_free(newNode);
+ return NULL;
+ }
newNode->nodeType = eTEXT_NODE;
}
@@ -683,15 +692,24 @@ static IXML_CDATASection *ixmlNode_cloneCDATASect(
IXML_CDATASection *newCDATA = NULL;
IXML_Node *newNode;
IXML_Node *srcNode;
+ int rc;
assert(nodeptr != NULL);
newCDATA = (IXML_CDATASection *)malloc(sizeof (IXML_CDATASection));
if (newCDATA != NULL) {
newNode = (IXML_Node *)newCDATA;
- ixmlNode_init(newNode);
+ ixmlCDATASection_init(newCDATA);
srcNode = (IXML_Node *)nodeptr;
- ixmlNode_setNodeName(newNode, srcNode->nodeName);
- ixmlNode_setNodeValue(newNode, srcNode->nodeValue);
+ rc = ixmlNode_setNodeName(newNode, srcNode->nodeName);
+ if (rc != IXML_SUCCESS) {
+ ixmlCDATASection_free(newCDATA);
+ return NULL;
+ }
+ rc = ixmlNode_setNodeValue(newNode, srcNode->nodeValue);
+ if (rc != IXML_SUCCESS) {
+ ixmlCDATASection_free(newCDATA);
+ return NULL;
+ }
newNode->nodeType = eCDATA_SECTION_NODE;
}
Please sign in to comment.
Something went wrong with that request. Please try again.