1
0
mirror of https://github.com/php/php-src.git synced 2026-04-14 11:32:11 +02:00

Make exception code more robust

This commit is contained in:
Marcus Boerger
2003-08-23 14:22:28 +00:00
parent 6b92fbdef9
commit 43334207ab
2 changed files with 22 additions and 32 deletions

View File

@@ -26,34 +26,29 @@ zend_class_entry *default_exception_ptr;
ZEND_FUNCTION(exception)
{
zval **message;
zval **code;
char *message = NULL;
long code = 0;
zval *tmp;
zval *object;
int argc = ZEND_NUM_ARGS();
int argc = ZEND_NUM_ARGS(), message_len;
if (zend_get_parameters_ex(argc, &message, &code) == FAILURE) {
ZEND_WRONG_PARAM_COUNT();
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, "|sl", &message, &message_len, &code) == FAILURE) {
zend_error(E_CORE_ERROR, "Wrong parameter count for exception([string $exception [, long $code ]])");
}
object = getThis();
if (argc > 0) {
convert_to_string_ex(message);
zval_add_ref(message);
zend_hash_update(Z_OBJPROP_P(object), "message", sizeof("message"), (void **) message, sizeof(zval *), NULL);
}
MAKE_STD_ZVAL(tmp);
ZVAL_STRING(tmp, message ? message : "Unknown exception", 1);
zend_hash_update(Z_OBJPROP_P(object), "message", sizeof("message"), (void **) &tmp, sizeof(zval *), NULL);
if (argc > 1) {
convert_to_long_ex(code);
zval_add_ref(code);
zend_hash_update(Z_OBJPROP_P(object), "code", sizeof("code"), (void **) code, sizeof(zval *), NULL);
}
MAKE_STD_ZVAL(tmp);
ZVAL_LONG(tmp, code);
zend_hash_update(Z_OBJPROP_P(object), "code", sizeof("code"), (void **) &tmp, sizeof(zval *), NULL);
MAKE_STD_ZVAL(tmp);
ZVAL_STRING(tmp, zend_get_executed_filename(TSRMLS_C), 1);
zend_hash_update(Z_OBJPROP_P(object), "file", sizeof("file"), (void **) &tmp, sizeof(zval *), NULL);
tmp = NULL;
MAKE_STD_ZVAL(tmp);
ZVAL_LONG(tmp, zend_get_executed_lineno(TSRMLS_C));

View File

@@ -26,34 +26,29 @@ zend_class_entry *default_exception_ptr;
ZEND_FUNCTION(exception)
{
zval **message;
zval **code;
char *message = NULL;
long code = 0;
zval *tmp;
zval *object;
int argc = ZEND_NUM_ARGS();
int argc = ZEND_NUM_ARGS(), message_len;
if (zend_get_parameters_ex(argc, &message, &code) == FAILURE) {
ZEND_WRONG_PARAM_COUNT();
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, "|sl", &message, &message_len, &code) == FAILURE) {
zend_error(E_CORE_ERROR, "Wrong parameter count for exception([string $exception [, long $code ]])");
}
object = getThis();
if (argc > 0) {
convert_to_string_ex(message);
zval_add_ref(message);
zend_hash_update(Z_OBJPROP_P(object), "message", sizeof("message"), (void **) message, sizeof(zval *), NULL);
}
MAKE_STD_ZVAL(tmp);
ZVAL_STRING(tmp, message ? message : "Unknown exception", 1);
zend_hash_update(Z_OBJPROP_P(object), "message", sizeof("message"), (void **) &tmp, sizeof(zval *), NULL);
if (argc > 1) {
convert_to_long_ex(code);
zval_add_ref(code);
zend_hash_update(Z_OBJPROP_P(object), "code", sizeof("code"), (void **) code, sizeof(zval *), NULL);
}
MAKE_STD_ZVAL(tmp);
ZVAL_LONG(tmp, code);
zend_hash_update(Z_OBJPROP_P(object), "code", sizeof("code"), (void **) &tmp, sizeof(zval *), NULL);
MAKE_STD_ZVAL(tmp);
ZVAL_STRING(tmp, zend_get_executed_filename(TSRMLS_C), 1);
zend_hash_update(Z_OBJPROP_P(object), "file", sizeof("file"), (void **) &tmp, sizeof(zval *), NULL);
tmp = NULL;
MAKE_STD_ZVAL(tmp);
ZVAL_LONG(tmp, zend_get_executed_lineno(TSRMLS_C));