chregu Sun Aug 8 14:01:33 2004 EDT Modified files: /php-src/ext/xsl xsltprocessor.c Log: - Fix bug #29573: Segmentation fault when php function(called from XSLT templat) throw exception - Fix some 0 Byte Memory Leaks http://cvs.php.net/diff.php/php-src/ext/xsl/xsltprocessor.c?r1=1.31&r2=1.32&ty=u Index: php-src/ext/xsl/xsltprocessor.c diff -u php-src/ext/xsl/xsltprocessor.c:1.31 php-src/ext/xsl/xsltprocessor.c:1.32 --- php-src/ext/xsl/xsltprocessor.c:1.31 Thu Aug 5 09:31:17 2004 +++ php-src/ext/xsl/xsltprocessor.c Sun Aug 8 14:01:33 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: xsltprocessor.c,v 1.31 2004/08/05 13:31:17 tony2001 Exp $ */ +/* $Id: xsltprocessor.c,v 1.32 2004/08/08 18:01:33 chregu Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -156,8 +156,10 @@ } fci.param_count = nargs - 1; - fci.params = safe_emalloc(fci.param_count, sizeof(zval**), 0); - args = safe_emalloc(fci.param_count, sizeof(zval *), 0); + if (fci.param_count > 0) { + fci.params = safe_emalloc(fci.param_count, sizeof(zval**), 0); + args = safe_emalloc(fci.param_count, sizeof(zval *), 0); + } /* Reverse order to pop values off ctxt stack */ for (i = nargs - 2; i >= 0; i--) { obj = valuePop(ctxt); @@ -228,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); @@ -253,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; @@ -282,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