Browse Source

MFH: fix #41421 (Uncaught exception from a stream wrapper segfaults)

experimental/5.2-WITH_DRCP
Antony Dovgal 19 years ago
parent
commit
d7b30e457a
  1. 29
      Zend/tests/bug41421.phpt
  2. 8
      Zend/zend_execute_API.c

29
Zend/tests/bug41421.phpt

@ -0,0 +1,29 @@
--TEST--
Bug #41421 (Uncaught exception from a stream wrapper segfaults)
--FILE--
<?php
class wrapper {
function stream_open() {
return true;
}
function stream_eof() {
throw new exception();
}
}
stream_wrapper_register("wrap", "wrapper");
$fp = fopen("wrap://...", "r");
feof($fp);
echo "Done\n";
?>
--EXPECTF--
Warning: feof(): wrapper::stream_eof is not implemented! Assuming EOF in %s on line %d
Fatal error: Uncaught exception 'Exception' in %s:%d
Stack trace:
#0 [internal function]: wrapper->stream_eof()
#1 %s(%d): feof(Resource id #6)
#2 {main}
thrown in %s on line %d

8
Zend/zend_execute_API.c

@ -675,6 +675,10 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
}
if (fci->object_pp) {
if (Z_TYPE_PP(fci->object_pp) == IS_OBJECT
&& (!EG(objects_store).object_buckets || !EG(objects_store).object_buckets[Z_OBJ_HANDLE_PP(fci->object_pp)].valid)) {
return FAILURE;
}
/* TBI!! new object handlers */
if (Z_TYPE_PP(fci->object_pp) == IS_OBJECT) {
if (!IS_ZEND_STD_OBJECT(**fci->object_pp)) {
@ -839,6 +843,10 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
calling_scope = fci_cache->calling_scope;
fci->object_pp = fci_cache->object_pp;
EX(object) = fci->object_pp ? *fci->object_pp : NULL;
if (fci->object_pp && Z_TYPE_PP(fci->object_pp) == IS_OBJECT
&& (!EG(objects_store).object_buckets || !EG(objects_store).object_buckets[Z_OBJ_HANDLE_PP(fci->object_pp)].valid)) {
return FAILURE;
}
}
if (EX(function_state).function->common.fn_flags & (ZEND_ACC_ABSTRACT|ZEND_ACC_DEPRECATED)) {

Loading…
Cancel
Save