Browse Source

Fixed bug #61442 (exception threw in __autoload can not be catched)

pull/200/head
Xinchen Hui 14 years ago
parent
commit
fd0b3ea663
  1. 2
      NEWS
  2. 30
      Zend/tests/bug61442.phpt
  3. 6
      Zend/zend_vm_def.h
  4. 39
      Zend/zend_vm_execute.h

2
NEWS

@ -9,6 +9,8 @@ PHP NEWS
some builtin classes). (Laruence)
. Fixed bug #61767 (Shutdown functions not called in certain error
situation). (Dmitry)
. Fixed bug #61442 (exception threw in __autoload can not be catched).
(Laruence)
. Fixed bug #60909 (custom error handler throwing Exception + fatal error
= no shutdown function). (Dmitry)

30
Zend/tests/bug61442.phpt

@ -0,0 +1,30 @@
--TEST--
Bug #61442 (exception threw in __autoload can not be catched)
--FILE--
<?php
function __autoload($name) {
throw new Exception("Unable to load $name");
}
try {
$obj = new NonLoadableClass();
} catch (Exception $e) {
var_dump($e->getMessage());
}
try {
$obj = NonLoadableClass::a();
} catch (Exception $e) {
var_dump($e->getMessage());
}
try {
$obj = NonLoadableClass::UNDEFINED_CONST;
} catch (Exception $e) {
var_dump($e->getMessage());
}
--EXPECTF--
string(31) "Unable to load NonLoadableClass"
string(31) "Unable to load NonLoadableClass"
string(31) "Unable to load NonLoadableClass"

6
Zend/zend_vm_def.h

@ -1990,6 +1990,9 @@ ZEND_VM_HANDLER(113, ZEND_INIT_STATIC_METHOD_CALL, CONST|VAR, CONST|TMP|VAR|UNUS
if (OP1_TYPE == IS_CONST) {
/* no function found. try a static method in class */
ce = zend_fetch_class(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant), opline->extended_value TSRMLS_CC);
if (UNEXPECTED(EG(exception) != NULL)) {
ZEND_VM_CONTINUE();
}
if (!ce) {
zend_error_noreturn(E_ERROR, "Class '%s' not found", Z_STRVAL(opline->op1.u.constant));
}
@ -3043,6 +3046,9 @@ ZEND_VM_HANDLER(99, ZEND_FETCH_CONSTANT, VAR|CONST|UNUSED, CONST)
if (OP1_TYPE == IS_CONST) {
ce = zend_fetch_class(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant), opline->extended_value TSRMLS_CC);
if (UNEXPECTED(EG(exception) != NULL)) {
ZEND_VM_CONTINUE();
}
if (!ce) {
zend_error_noreturn(E_ERROR, "Undefined class constant '%s'", Z_STRVAL(opline->op2.u.constant));
}

39
Zend/zend_vm_execute.h

@ -2688,6 +2688,9 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_CONST_HANDLER(
if (IS_CONST == IS_CONST) {
/* no function found. try a static method in class */
ce = zend_fetch_class(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant), opline->extended_value TSRMLS_CC);
if (UNEXPECTED(EG(exception) != NULL)) {
ZEND_VM_CONTINUE();
}
if (!ce) {
zend_error_noreturn(E_ERROR, "Class '%s' not found", Z_STRVAL(opline->op1.u.constant));
}
@ -2836,6 +2839,9 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_CONST_CONST_HANDLER(ZEND_OPCO
if (IS_CONST == IS_CONST) {
ce = zend_fetch_class(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant), opline->extended_value TSRMLS_CC);
if (UNEXPECTED(EG(exception) != NULL)) {
ZEND_VM_CONTINUE();
}
if (!ce) {
zend_error_noreturn(E_ERROR, "Undefined class constant '%s'", Z_STRVAL(opline->op2.u.constant));
}
@ -3259,6 +3265,9 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_TMP_HANDLER(ZE
if (IS_CONST == IS_CONST) {
/* no function found. try a static method in class */
ce = zend_fetch_class(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant), opline->extended_value TSRMLS_CC);
if (UNEXPECTED(EG(exception) != NULL)) {
ZEND_VM_CONTINUE();
}
if (!ce) {
zend_error_noreturn(E_ERROR, "Class '%s' not found", Z_STRVAL(opline->op1.u.constant));
}
@ -3725,6 +3734,9 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_VAR_HANDLER(ZE
if (IS_CONST == IS_CONST) {
/* no function found. try a static method in class */
ce = zend_fetch_class(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant), opline->extended_value TSRMLS_CC);
if (UNEXPECTED(EG(exception) != NULL)) {
ZEND_VM_CONTINUE();
}
if (!ce) {
zend_error_noreturn(E_ERROR, "Class '%s' not found", Z_STRVAL(opline->op1.u.constant));
}
@ -3947,6 +3959,9 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_UNUSED_HANDLER
if (IS_CONST == IS_CONST) {
/* no function found. try a static method in class */
ce = zend_fetch_class(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant), opline->extended_value TSRMLS_CC);
if (UNEXPECTED(EG(exception) != NULL)) {
ZEND_VM_CONTINUE();
}
if (!ce) {
zend_error_noreturn(E_ERROR, "Class '%s' not found", Z_STRVAL(opline->op1.u.constant));
}
@ -4381,6 +4396,9 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_CV_HANDLER(ZEN
if (IS_CONST == IS_CONST) {
/* no function found. try a static method in class */
ce = zend_fetch_class(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant), opline->extended_value TSRMLS_CC);
if (UNEXPECTED(EG(exception) != NULL)) {
ZEND_VM_CONTINUE();
}
if (!ce) {
zend_error_noreturn(E_ERROR, "Class '%s' not found", Z_STRVAL(opline->op1.u.constant));
}
@ -10498,6 +10516,9 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_CONST_HANDLER(ZE
if (IS_VAR == IS_CONST) {
/* no function found. try a static method in class */
ce = zend_fetch_class(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant), opline->extended_value TSRMLS_CC);
if (UNEXPECTED(EG(exception) != NULL)) {
ZEND_VM_CONTINUE();
}
if (!ce) {
zend_error_noreturn(E_ERROR, "Class '%s' not found", Z_STRVAL(opline->op1.u.constant));
}
@ -10646,6 +10667,9 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE
if (IS_VAR == IS_CONST) {
ce = zend_fetch_class(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant), opline->extended_value TSRMLS_CC);
if (UNEXPECTED(EG(exception) != NULL)) {
ZEND_VM_CONTINUE();
}
if (!ce) {
zend_error_noreturn(E_ERROR, "Undefined class constant '%s'", Z_STRVAL(opline->op2.u.constant));
}
@ -12305,6 +12329,9 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_TMP_HANDLER(ZEND
if (IS_VAR == IS_CONST) {
/* no function found. try a static method in class */
ce = zend_fetch_class(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant), opline->extended_value TSRMLS_CC);
if (UNEXPECTED(EG(exception) != NULL)) {
ZEND_VM_CONTINUE();
}
if (!ce) {
zend_error_noreturn(E_ERROR, "Class '%s' not found", Z_STRVAL(opline->op1.u.constant));
}
@ -14107,6 +14134,9 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_VAR_HANDLER(ZEND
if (IS_VAR == IS_CONST) {
/* no function found. try a static method in class */
ce = zend_fetch_class(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant), opline->extended_value TSRMLS_CC);
if (UNEXPECTED(EG(exception) != NULL)) {
ZEND_VM_CONTINUE();
}
if (!ce) {
zend_error_noreturn(E_ERROR, "Class '%s' not found", Z_STRVAL(opline->op1.u.constant));
}
@ -15003,6 +15033,9 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_UNUSED_HANDLER(Z
if (IS_VAR == IS_CONST) {
/* no function found. try a static method in class */
ce = zend_fetch_class(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant), opline->extended_value TSRMLS_CC);
if (UNEXPECTED(EG(exception) != NULL)) {
ZEND_VM_CONTINUE();
}
if (!ce) {
zend_error_noreturn(E_ERROR, "Class '%s' not found", Z_STRVAL(opline->op1.u.constant));
}
@ -16496,6 +16529,9 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_CV_HANDLER(ZEND_
if (IS_VAR == IS_CONST) {
/* no function found. try a static method in class */
ce = zend_fetch_class(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant), opline->extended_value TSRMLS_CC);
if (UNEXPECTED(EG(exception) != NULL)) {
ZEND_VM_CONTINUE();
}
if (!ce) {
zend_error_noreturn(E_ERROR, "Class '%s' not found", Z_STRVAL(opline->op1.u.constant));
}
@ -17860,6 +17896,9 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_UNUSED_CONST_HANDLER(ZEND_OPC
if (IS_UNUSED == IS_CONST) {
ce = zend_fetch_class(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant), opline->extended_value TSRMLS_CC);
if (UNEXPECTED(EG(exception) != NULL)) {
ZEND_VM_CONTINUE();
}
if (!ce) {
zend_error_noreturn(E_ERROR, "Undefined class constant '%s'", Z_STRVAL(opline->op2.u.constant));
}

Loading…
Cancel
Save