cvs: php4(PHP_4_2_0) /ext/domxml php_domxml.c

From: Date: Tue, 27 Aug 2002 06:56:37 +0000
Subject: cvs: php4(PHP_4_2_0) /ext/domxml php_domxml.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-13698@lists.php.net to get a copy of this message
chregu Tue Aug 27 02:56:37 2002 EDT Modified files: (Branch: PHP_4_2_0) /php4/ext/domxml php_domxml.c Log: MFH (fix memleak in php_domxslt_string_to_xpathexpr) Index: php4/ext/domxml/php_domxml.c diff -u php4/ext/domxml/php_domxml.c:1.118.2.13 php4/ext/domxml/php_domxml.c:1.118.2.14 --- php4/ext/domxml/php_domxml.c:1.118.2.13 Mon Aug 19 03:27:33 2002 +++ php4/ext/domxml/php_domxml.c Tue Aug 27 02:56:36 2002 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_domxml.c,v 1.118.2.13 2002/08/19 07:27:33 chregu Exp $ */ +/* $Id: php_domxml.c,v 1.118.2.14 2002/08/27 06:56:36 chregu Exp $ */ /* TODO * - Support Notation Nodes @@ -4210,20 +4210,21 @@ const xmlChar *string = (const xmlChar *)str; xmlChar *value; - + int str_len; + + str_len = xmlStrlen(string) + 3; + if (xmlStrchr(string, '"')) { if (xmlStrchr(string, '\'')) { - php_error(E_WARNING, "Cannot create XPath expression (string contains both quote and double-quotes) in %s", + php_error(E_WARNING, "%s(): Cannot create XPath expression (string contains both quote and double-quotes)", get_active_function_name(TSRMLS_C)); return NULL; } - value = xmlStrdup((const xmlChar *)"'"); - value = xmlStrcat(value, string); - value = xmlStrcat(value, (const xmlChar *)"'"); + value = (xmlChar*) emalloc (str_len * sizeof(xmlChar *) ); + snprintf(value, str_len, "'%s'", string); } else { - value = xmlStrdup((const xmlChar *)"\""); - value = xmlStrcat(value, string); - value = xmlStrcat(value, (const xmlChar *)"\""); + value = (xmlChar*) emalloc (str_len * sizeof(xmlChar *) ); + snprintf(value, str_len, "\"%s\"", string); } return (char *)value;

« previous php.cvs (#13698) next »