chregu Sun Aug 8 14:05:47 2004 EDT
Modified files: (Branch: PHP_5_0)
/php-src/ext/xsl xsltprocessor.c
Log:
MFH (fix for Bug #29573 : Segmentation fault when php function(called from XSLT
templat) throw exception
and Zero Byte Memory Leaks)
http://cvs.php.net/diff.php/php-src/ext/xsl/xsltprocessor.c?r1=1.29.2.1&r2=1.29.2.2&ty=u
Index: php-src/ext/xsl/xsltprocessor.c
diff -u php-src/ext/xsl/xsltprocessor.c:1.29.2.1
php-src/ext/xsl/xsltprocessor.c:1.29.2.2
--- php-src/ext/xsl/xsltprocessor.c:1.29.2.1 Wed Jul 28 08:42:16 2004
+++ php-src/ext/xsl/xsltprocessor.c Sun Aug 8 14:05:47 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: xsltprocessor.c,v 1.29.2.1 2004/07/28 12:42:16 chregu Exp $ */
+/* $Id: xsltprocessor.c,v 1.29.2.2 2004/08/08 18:05:47 chregu Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -156,9 +156,10 @@
}
fci.param_count = nargs - 1;
- fci.params = safe_emalloc(fci.param_count, sizeof(zval**), 0);
-
- args = safe_emalloc(nargs - 1, sizeof(zval *), 0);
+ if (fci.param_count > 0) {
+ fci.params = safe_emalloc(fci.param_count, sizeof(zval**), 0);
+ args = safe_emalloc(nargs - 1, sizeof(zval *), 0);
+ }
/* Reverse order to pop values off ctxt stack */
for (i = nargs - 2; i >= 0; i--) {
obj = valuePop(ctxt);
@@ -229,11 +230,13 @@
if (obj->stringval == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Handler name must be a
string");
xmlXPathFreeObject(obj);
- for (i = 0; i < nargs - 1; i++) {
- zval_ptr_dtor(&args[i]);
+ if (fci.param_count > 0) {
+ for (i = 0; i < nargs - 1; i++) {
+ zval_ptr_dtor(&args[i]);
+ }
+ efree(args);
+ efree(fci.params);
}
- efree(args);
- efree(fci.params);
return;
}
INIT_PZVAL(&handler);
@@ -254,7 +257,9 @@
if (result == FAILURE) {
if (Z_TYPE(handler) == IS_STRING) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to
call handler %s()", Z_STRVAL_P(&handler));
- }
+ }
+ /* retval is == NULL, when an exception occured, don't report
anything, because PHP itself will handle that */
+ } else if (retval == NULL) {
} else {
if (retval->type == IS_OBJECT && instanceof_function(
Z_OBJCE_P(retval), dom_node_class_entry TSRMLS_CC)) {
xmlNode *nodep;
@@ -283,11 +288,13 @@
}
efree(callable);
zval_dtor(&handler);
- for (i = 0; i < nargs - 1; i++) {
- zval_ptr_dtor(&args[i]);
+ if (fci.param_count > 0) {
+ for (i = 0; i < nargs - 1; i++) {
+ zval_ptr_dtor(&args[i]);
+ }
+ efree(args);
+ efree(fci.params);
}
- efree(args);
- efree(fci.params);
}
static void xsl_ext_function_string_php(xmlXPathParserContextPtr ctxt, int nargs)
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php