Re: [PHP4BETA] cvs: /php4/ext/standard info.c
| From: | Andreas Pour | Date: | Wed, 05 Apr 2000 20:57:01 +0000 |
| Subject: | Re: [PHP4BETA] cvs: /php4/ext/standard info.c | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-13188@lists.php.net to get a copy of this message | ||
Colin Viebrock wrote:
>
> cmv Wed Apr 5 13:29:50 2000 EDT
>
> Modified files:
> /php4/ext/standard info.c
> Log:
> fixed the segfault problem (probably not the prettiest way, but)
[ ... ]
> + int tmp_zend_debug;
>
> #ifdef PHP_WIN32
> char php_windows_uname[256];
> @@ -168,9 +169,10 @@
> php_info_print_table_row(2, "Configure Command", CONFIGURE_COMMAND );
> #endif
> php_info_print_table_row(2, "php.ini Path", CONFIGURATION_FILE_PATH
> );
> -/* why does this cause seg faults?
> - php_info_print_table_row(2, "ZEND_DEBUG", ZEND_DEBUG );
> -*/
> +
> + sprintf(tmp_zend_debug, "%d", ZEND_DEBUG);
> + php_info_print_table_row(2, "ZEND_DEBUG", tmp_zend_debug );
> +
Funny, I thought sprintf takes a (char *) as its first arg. I don't see
why this wouldn't seg fault quite regularly; you're writing into
whatever address happens to be on the stack. Moreover, the value of
tmp_zend_debug in the call to php_info_print_table_row is undefined and
gets dereferenced as a char* in php_info_print_table_row. Curious that
this works for you . . . .
Anyway, the reason it segfaulted before is that php_info_print_table_row
expects all char*s as args. ZEND_DEBUG if I follow the .h files
correctly is either set to 1 or unset. I think the way it should be
written is:
#ifdef ZEND_DEBUG
php_info_print_table_row(2, "ZEND_DEBUG", "true" )
#else
php_info_print_table_row(2, "ZEND_DEBUG", "false" )
#endif
Ciao,
Andreas