diff options
author | Christian Stocker <chregu@php.net> | 2002-08-27 06:56:36 +0000 |
---|---|---|
committer | Christian Stocker <chregu@php.net> | 2002-08-27 06:56:36 +0000 |
commit | 638471d549674978987a9cb14a68a43d2c6ca2b9 (patch) | |
tree | 59240a19abd54162314f2ade050928e324d08224 /ext/domxml/php_domxml.c | |
parent | c0f896f1f617647141fed2509193a19406513e6c (diff) | |
download | php-git-638471d549674978987a9cb14a68a43d2c6ca2b9.tar.gz |
MFH (fix memleak in php_domxslt_string_to_xpathexpr)
Diffstat (limited to 'ext/domxml/php_domxml.c')
-rw-r--r-- | ext/domxml/php_domxml.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/ext/domxml/php_domxml.c b/ext/domxml/php_domxml.c index 9ec097e4ed..94f86288d8 100644 --- a/ext/domxml/php_domxml.c +++ b/ext/domxml/php_domxml.c @@ -4210,20 +4210,21 @@ static char *php_domxslt_string_to_xpathexpr(const char *str TSRMLS_DC) 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; |