diff options
author | Christian Stocker <chregu@php.net> | 2002-08-27 06:54:21 +0000 |
---|---|---|
committer | Christian Stocker <chregu@php.net> | 2002-08-27 06:54:21 +0000 |
commit | e0b4533eeb4df9444174c026c53791f3187c2a9f (patch) | |
tree | cce1614b4a1a24e5fbdf0f6543b92c0de7167157 /ext/domxml/php_domxml.c | |
parent | 61f70a3cb7f0e54625badac1cbeed73b8039e4fd (diff) | |
download | php-git-e0b4533eeb4df9444174c026c53791f3187c2a9f.tar.gz |
fix memleak in php_domxslt_string_to_xpathexpr
Diffstat (limited to 'ext/domxml/php_domxml.c')
-rw-r--r-- | ext/domxml/php_domxml.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/ext/domxml/php_domxml.c b/ext/domxml/php_domxml.c index 7b34a5f379..14e0d1d939 100644 --- a/ext/domxml/php_domxml.c +++ b/ext/domxml/php_domxml.c @@ -5051,20 +5051,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, "%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; |