Browse Source

fix #40815 (using strings like "class::func" and static methods in set_exception_handler() might result in crash)

experimental/5.2-WITH_DRCP
Antony Dovgal 20 years ago
parent
commit
79ed194a64
  1. 18
      Zend/tests/bug40815.phpt
  2. 3
      Zend/zend.c
  3. 2
      Zend/zend_execute_API.c

18
Zend/tests/bug40815.phpt

@ -0,0 +1,18 @@
--TEST--
Bug #40815 (using strings like "class::func" and static methods in set_exception_handler() might result in crash).
--FILE--
<?php
class ehandle{
static public function exh ($ex) {
echo 'foo';
}
}
set_exception_handler("ehandle::exh");
throw new Exception ("Whiii");
echo "Done\n";
?>
--EXPECTF--
foo

3
Zend/zend.c

@ -1146,6 +1146,9 @@ ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval **retval, int file_co
zval_ptr_dtor(&retval2);
}
} else {
if (!EG(exception)) {
EG(exception) = old_exception;
}
zend_exception_error(EG(exception) TSRMLS_CC);
}
efree(params);

2
Zend/zend_execute_API.c

@ -750,7 +750,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
fname = Z_STRVAL_P(fci->function_name);
fname_len = Z_STRLEN_P(fci->function_name);
if (calling_scope && (colon = strstr(fname, "::")) != NULL) {
if ((colon = strstr(fname, "::")) != NULL) {
int clen = colon - fname;
int mlen = fname_len - clen - 2;
zend_class_entry **pce, *ce_child = NULL;

Loading…
Cancel
Save