mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Merge branch 'PHP-5.3' into PHP-5.4
* PHP-5.3: Fixed bug #64821 Custom Exceptions crash when internal properties overridden
This commit is contained in:
commit
dd188e9538
4 changed files with 70 additions and 1 deletions
22
Zend/tests/bug64821.1.phpt
Normal file
22
Zend/tests/bug64821.1.phpt
Normal file
|
@ -0,0 +1,22 @@
|
|||
--TEST--
|
||||
Bug #64821 Custom Exceptions crash when internal properties overridden (variation 1)
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
class a extends exception {
|
||||
public function __construct() {
|
||||
$this->message = NULL;
|
||||
$this->string = NULL;
|
||||
$this->code = array();
|
||||
$this->line = "hello";
|
||||
}
|
||||
}
|
||||
|
||||
throw new a;
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Uncaught exception 'a' in %s:0
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in %s on line %d
|
19
Zend/tests/bug64821.2.phpt
Normal file
19
Zend/tests/bug64821.2.phpt
Normal file
|
@ -0,0 +1,19 @@
|
|||
--TEST--
|
||||
Bug #64821 Custom Exceptions crash when internal properties overridden (variation 2)
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
class a extends exception {
|
||||
public function __construct() {
|
||||
$this->line = array();
|
||||
}
|
||||
}
|
||||
|
||||
throw new a;
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Uncaught exception 'a' in %s:0
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in %s on line %d
|
20
Zend/tests/bug64821.3.phpt
Normal file
20
Zend/tests/bug64821.3.phpt
Normal file
|
@ -0,0 +1,20 @@
|
|||
--TEST--
|
||||
Bug #64821 Custom Exceptions crash when internal properties overridden (variation 3)
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
class a extends exception {
|
||||
public function __construct() {
|
||||
$this->line = array();
|
||||
$this->file = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
throw new a;
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Uncaught exception 'a' in :0
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in Unknown on line %d
|
|
@ -817,6 +817,10 @@ ZEND_API void zend_exception_error(zval *exception, int severity TSRMLS_DC) /* {
|
|||
if (instanceof_function(ce_exception, default_exception_ce TSRMLS_CC)) {
|
||||
file = zend_read_property(default_exception_ce, EG(exception), "file", sizeof("file")-1, 1 TSRMLS_CC);
|
||||
line = zend_read_property(default_exception_ce, EG(exception), "line", sizeof("line")-1, 1 TSRMLS_CC);
|
||||
|
||||
convert_to_string(file);
|
||||
file = (Z_STRLEN_P(file) > 0) ? file : NULL;
|
||||
line = (Z_TYPE_P(line) == IS_LONG) ? line : NULL;
|
||||
} else {
|
||||
file = NULL;
|
||||
line = NULL;
|
||||
|
@ -828,7 +832,11 @@ ZEND_API void zend_exception_error(zval *exception, int severity TSRMLS_DC) /* {
|
|||
file = zend_read_property(default_exception_ce, exception, "file", sizeof("file")-1, 1 TSRMLS_CC);
|
||||
line = zend_read_property(default_exception_ce, exception, "line", sizeof("line")-1, 1 TSRMLS_CC);
|
||||
|
||||
zend_error_va(severity, Z_STRVAL_P(file), Z_LVAL_P(line), "Uncaught %s\n thrown", Z_STRVAL_P(str));
|
||||
convert_to_string(str);
|
||||
convert_to_string(file);
|
||||
convert_to_long(line);
|
||||
|
||||
zend_error_va(severity, (Z_STRLEN_P(file) > 0) ? Z_STRVAL_P(file) : NULL, Z_LVAL_P(line), "Uncaught %s\n thrown", Z_STRVAL_P(str));
|
||||
} else {
|
||||
zend_error(severity, "Uncaught exception '%s'", ce_exception->name);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue