Patch incl: Sablotron compile problems/segfaults

From: Date: Fri, 24 Nov 2000 00:14:02 +0000
Subject: Patch incl: Sablotron compile problems/segfaults
Groups: php.dev 
Request: Send a blank email to php-dev+get-39056@lists.php.net to get a copy of this message
The output buffering patch Andi committed a few hours ago means that the Sablot ext needs a tiny patch to supply the chunk_size parameter. Also, xslt_transform() now segfaults when either of xslt_params or xslt_args are given and 0. Both problems are fixed by the patch below. I'm pretty sure Sterling has a reason for testing IS_LONG, 0, and IS_NULL as special cases, but I missed the point and so the below patch just tests for IS_ARRAY. Seems like neither param would have much use if they aren't arrays anyway. :) Index: sablot.c =================================================================== RCS file: /repository/php4/ext/sablot/sablot.c,v retrieving revision 1.16 diff -u -r1.16 sablot.c --- sablot.c 2000/11/23 14:02:41 1.16 +++ sablot.c 2000/11/24 00:00:34 @@ -225,7 +225,7 @@ * Start output buffering, NULL signifies that no "user-space" output function * will be used. */ - php_start_ob_buffer(NULL); + php_start_ob_buffer(NULL, 0); } /* }}} */ @@ -342,30 +342,27 @@ * the third argument and decide whether or not there are Sablotron * parameters. */ - if (argc > 3) { - if (Z_TYPE_PP(xslt_params) != IS_LONG || Z_LVAL_PP(xslt_params) != 0 || - Z_TYPE_PP(xslt_params) != IS_NULL) { - int numelems, - size; - HashTable *ar = HASH_OF(*xslt_params); - - /** - * Allocate 2 times the number of elements in - * the array, since with associative arrays in PHP - * keys are not counted. - */ - numelems = zend_hash_num_elements(ar); - size = (numelems * 2 + 1) * sizeof(char *); - - params = (char **)emalloc(size+1); - memset((char *)params, 0, size); - - /** - * Translate a PHP array (HashTable *) into a - * Sablotron array (char **). - */ - _php_sablot_ht_char(ar, params); - } + if (argc > 3 && Z_TYPE_PP(xslt_params) == IS_ARRAY) { + int numelems, + size; + HashTable *ar = HASH_OF(*xslt_params); + + /** + * Allocate 2 times the number of elements in + * the array, since with associative arrays in PHP + * keys are not counted. + */ + numelems = zend_hash_num_elements(ar); + size = (numelems * 2 + 1) * sizeof(char *); + + params = (char **)emalloc(size+1); + memset((char *)params, 0, size); + + /** + * Translate a PHP array (HashTable *) into a + * Sablotron array (char **). + */ + _php_sablot_ht_char(ar, params); } /** @@ -373,21 +370,18 @@ * of the 4 argument and decide whether or not there are Sablotron * arguments. */ - if (argc > 4) { - if (Z_TYPE_PP(xslt_args) != IS_LONG || Z_LVAL_PP(xslt_args) != 0 || - Z_TYPE_PP(xslt_args) != IS_NULL) { - int numelems, - size; - HashTable *ar = HASH_OF(*xslt_args); - - numelems = zend_hash_num_elements(ar); - size = (numelems * 2 + 1) * sizeof(char *); - - args = (char **)emalloc(size+1); - memset((char *)args, 0, size); - - _php_sablot_ht_char(ar, args); - } + if (argc > 4 && Z_TYPE_PP(xslt_args) == IS_ARRAY) { + int numelems, + size; + HashTable *ar = HASH_OF(*xslt_args); + + numelems = zend_hash_num_elements(ar); + size = (numelems * 2 + 1) * sizeof(char *); + + args = (char **)emalloc(size+1); + memset((char *)args, 0, size); + + _php_sablot_ht_char(ar, args); } SABLOT_BASIC_CREATE_PROCESSOR(); -- +----------------------------------------------------------------+ |Torben Wilson <torben@php.net> Netmill iTech| |http://www.coastnet.com/~torben http://www.netmill.fi| |Ph: 1 250 383-9735 torben@netmill.fi| +----------------------------------------------------------------+

« previous php.dev (#39056) next »