Fixed return value of assert_options(ASSERT_CALLBACK) and possible crash (Andy Wharmby)

This commit is contained in:
Dmitry Stogov 2007-02-16 13:12:10 +00:00
parent 780c66d14b
commit 0262f05c17
2 changed files with 17 additions and 6 deletions

View File

@ -114,6 +114,16 @@ PHP_MSHUTDOWN_FUNCTION(assert)
return SUCCESS;
}
PHP_RINIT_FUNCTION(assert)
{
if (ASSERTG(cb)) {
MAKE_STD_ZVAL(ASSERTG(callback));
ZVAL_STRING(ASSERTG(callback), ASSERTG(cb), 1);
}
return SUCCESS;
}
PHP_RSHUTDOWN_FUNCTION(assert)
{
if (ASSERTG(callback)) {
@ -187,11 +197,6 @@ PHP_FUNCTION(assert)
RETURN_TRUE;
}
if (!ASSERTG(callback) && ASSERTG(cb)) {
MAKE_STD_ZVAL(ASSERTG(callback));
ZVAL_STRING(ASSERTG(callback), ASSERTG(cb), 1);
}
if (ASSERTG(callback)) {
zval *args[3];
zval *retval;
@ -286,6 +291,11 @@ PHP_FUNCTION(assert_options)
break;
case ASSERT_CALLBACK:
if (ASSERTG(callback) != NULL) {
RETVAL_ZVAL(ASSERTG(callback), 1, 0);
} else {
RETVAL_NULL();
}
if (ac == 2) {
if (ASSERTG(callback)) {
zval_ptr_dtor(&ASSERTG(callback));
@ -293,7 +303,7 @@ PHP_FUNCTION(assert_options)
ASSERTG(callback) = *value;
zval_add_ref(value);
}
RETURN_TRUE;
return;
break;
default:

View File

@ -4132,6 +4132,7 @@ PHP_RINIT_FUNCTION(basic)
#ifdef HAVE_SYSLOG_H
PHP_RINIT(syslog)(INIT_FUNC_ARGS_PASSTHRU);
#endif
PHP_RINIT(assert) (INIT_FUNC_ARGS_PASSTHRU);
PHP_RINIT(dir)(INIT_FUNC_ARGS_PASSTHRU);
PHP_RINIT(url_scanner_ex)(INIT_FUNC_ARGS_PASSTHRU);