cvs: php4 /ext/domxml php_domxml.c
| From: | Christian Stocker | Date: | Tue, 27 Aug 2002 06:54:21 +0000 |
| Subject: | cvs: php4 /ext/domxml php_domxml.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-13697@lists.php.net to get a copy of this message | ||
chregu Tue Aug 27 02:54:21 2002 EDT
Modified files:
/php4/ext/domxml php_domxml.c
Log:
fix memleak in php_domxslt_string_to_xpathexpr
Index: php4/ext/domxml/php_domxml.c
diff -u php4/ext/domxml/php_domxml.c:1.204 php4/ext/domxml/php_domxml.c:1.205
--- php4/ext/domxml/php_domxml.c:1.204 Fri Aug 23 11:26:19 2002
+++ php4/ext/domxml/php_domxml.c Tue Aug 27 02:54:21 2002
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_domxml.c,v 1.204 2002/08/23 15:26:19 chregu Exp $ */
+/* $Id: php_domxml.c,v 1.205 2002/08/27 06:54:21 chregu Exp $ */
/* TODO
* - Support Notation Nodes
@@ -5051,20 +5051,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, "%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 *)"'");
- } 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);
+ } else {
+ value = (xmlChar*) emalloc (str_len * sizeof(xmlChar *) );
+ snprintf(value, str_len, "\"%s\"", string);
}
return (char *)value;