cvs: php4 /ext/domxml php_domxml.c

From: Date: Thu, 04 Apr 2002 12:16:50 +0000
Subject: cvs: php4 /ext/domxml php_domxml.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-10853@lists.php.net to get a copy of this message
chregu Thu Apr 4 07:16:50 2002 EDT Modified files: /php4/ext/domxml php_domxml.c Log: - fixed a lot of memory leaks (by Lukas Schroeder) - get_attribute() returns False instead of empty string, if attribute not found Index: php4/ext/domxml/php_domxml.c diff -u php4/ext/domxml/php_domxml.c:1.132 php4/ext/domxml/php_domxml.c:1.133 --- php4/ext/domxml/php_domxml.c:1.132 Wed Mar 27 16:45:45 2002 +++ php4/ext/domxml/php_domxml.c Thu Apr 4 07:16:48 2002 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_domxml.c,v 1.132 2002/03/27 21:45:45 jtate Exp $ */ +/* $Id: php_domxml.c,v 1.133 2002/04/04 12:16:48 chregu Exp $ */ /* TODO * - Support Notation Nodes @@ -744,9 +744,7 @@ { zval *wrapper; - if (! found) { *found = 0; - } if (!obj) { MAKE_STD_ZVAL(wrapper); @@ -851,9 +849,7 @@ zval *wrapper; int rsrc_type; - if (! found) { *found = 0; - } if (!obj) { MAKE_STD_ZVAL(wrapper); @@ -937,9 +933,7 @@ char *content; int rsrc_type; - if (! found) { *found = 0; - } if (!obj) { MAKE_STD_ZVAL(wrapper); @@ -976,6 +970,7 @@ if (content) { add_property_long(wrapper, "type", Z_TYPE_P(nodep)); add_property_stringl(wrapper, "content", (char *) content, strlen(content), 1); + xmlFree(content); } break; } @@ -989,6 +984,7 @@ if (content) { add_property_long(wrapper, "type", Z_TYPE_P(nodep)); add_property_stringl(wrapper, "content", (char *) content, strlen(content), 1); + xmlFree(content); } break; } @@ -1000,8 +996,10 @@ rsrc_type = le_domxmlpip; content = xmlNodeGetContent(nodep); add_property_stringl(wrapper, "target", (char *) nodep->name, strlen(nodep->name), 1); - if (content) + if (content) { add_property_stringl(wrapper, "data", (char *) content, strlen(content), 1); + xmlFree(content); + } break; } @@ -1024,8 +1022,10 @@ add_property_stringl(wrapper, "name", (char *) nodep->name, strlen(nodep->name), 1); if (Z_TYPE_P(obj) == XML_ENTITY_REF_NODE) { content = xmlNodeGetContent(nodep); - if (content) + if (content) { add_property_stringl(wrapper, "content", (char *) content, strlen(content), 1); + xmlFree(content); + } } break; } @@ -1038,8 +1038,10 @@ add_property_stringl(wrapper, "name", (char *) attrp->name, strlen(attrp->name), 1); add_property_long(wrapper, "type", Z_TYPE_P(attrp)); content = xmlNodeGetContent((xmlNodePtr) attrp); - if (content) + if (content) { add_property_stringl(wrapper, "value", (char *) content, strlen(content), 1); + xmlFree(content); + } break; } @@ -1093,8 +1095,10 @@ rsrc_type = le_domxmlcdatap; content = xmlNodeGetContent(nodep); add_property_long(wrapper, "type", Z_TYPE_P(nodep)); - if (content) + if (content) { add_property_stringl(wrapper, "content", (char *) content, strlen(content), 1); + xmlFree(content); + } break; } @@ -1749,7 +1753,7 @@ } /* }}} */ -/* {{{ proto object domxml_node_prefix(void) +/* {{{ proto string domxml_node_prefix(void) Returns namespace prefix of node */ PHP_FUNCTION(domxml_node_prefix) { @@ -2103,7 +2107,8 @@ RETURN_FALSE; } - RETURN_STRING(mem,1); + RETVAL_STRING(mem,1); + xmlFree(mem); } /* }}} */ @@ -2201,9 +2206,10 @@ value = xmlGetProp(nodep, name); if (!value) { - RETURN_EMPTY_STRING(); + RETURN_FALSE; } else { - RETURN_STRING(value, 1); + RETVAL_STRING(value, 1); + xmlFree(value); } } /* }}} */ @@ -2242,8 +2248,7 @@ DOMXML_PARAM_TWO(nodep, id, le_domxmlelementp, "s", &name, &name_len); attrp = xmlHasProp(nodep,name); - if (attrp == NULL) - { + if (attrp == NULL) { RETURN_FALSE; } xmlUnlinkNode((xmlNodePtr)attrp); @@ -2263,8 +2268,7 @@ DOMXML_PARAM_TWO(nodep, id, le_domxmlelementp, "s", &name, &name_len); attrp = xmlHasProp(nodep,name); - if (attrp == NULL) - { + if (attrp == NULL) { RETURN_FALSE; } DOMXML_RET_OBJ(rv, (xmlNodePtr) attrp, &ret); @@ -2990,9 +2994,12 @@ htmlDocDumpMemory(docp, &mem, &size); if (!size) { + if (mem) + xmlFree(mem); RETURN_FALSE; } RETURN_STRINGL(mem, size, 1); + xmlFree(mem); } /* }}} */ @@ -3573,9 +3580,7 @@ zval *wrapper; int rsrc_type; - if (! found) { *found = 0; - } if (!obj) { MAKE_STD_ZVAL(wrapper);

« previous php.cvs (#10853) next »