cvs: ZendEngine2(PHP_5_2) / zend_execute_API.c /tests bug41209.phpt

From: Date: Fri, 27 Apr 2007 08:12:24 +0000
Subject: cvs: ZendEngine2(PHP_5_2) / zend_execute_API.c /tests bug41209.phpt
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-5752@lists.php.net to get a copy of this message
tony2001 Fri Apr 27 08:12:24 2007 UTC Added files: (Branch: PHP_5_2) /ZendEngine2/tests bug41209.phpt Modified files: /ZendEngine2 zend_execute_API.c Log: MFH: initialize retval_ptr_ptr before returning FAILURE this fixes invalid read in #41209 http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_execute_API.c?r1=1.331.2.20.2.18&r2=1.331.2.20.2.19&diff_format=u Index: ZendEngine2/zend_execute_API.c diff -u ZendEngine2/zend_execute_API.c:1.331.2.20.2.18 ZendEngine2/zend_execute_API.c:1.331.2.20.2.19 --- ZendEngine2/zend_execute_API.c:1.331.2.20.2.18 Mon Apr 16 08:09:54 2007 +++ ZendEngine2/zend_execute_API.c Fri Apr 27 08:12:24 2007 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_execute_API.c,v 1.331.2.20.2.18 2007/04/16 08:09:54 dmitry Exp $ */ +/* $Id: zend_execute_API.c,v 1.331.2.20.2.19 2007/04/27 08:12:24 tony2001 Exp $ */ #include <stdio.h> #include <signal.h> @@ -622,6 +622,8 @@ char *fname, *colon; int fname_len; + *fci->retval_ptr_ptr = NULL; + if (!EG(active)) { return FAILURE; /* executor is already inactive */ } @@ -652,11 +654,6 @@ memset(&execute_data, 0, sizeof(zend_execute_data)); } - /* we may return SUCCESS, and yet retval may be uninitialized, - * if there was an exception... - */ - *fci->retval_ptr_ptr = NULL; - if (!fci_cache || !fci_cache->initialized) { if (Z_TYPE_P(fci->function_name)==IS_ARRAY) { /* assume array($obj, $name) couple */ zval **tmp_object_ptr, **tmp_real_function_name; http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug41209.phpt?view=markup&rev=1.1 Index: ZendEngine2/tests/bug41209.phpt +++ ZendEngine2/tests/bug41209.phpt --TEST-- Bug #41209 (Segmentation fault with ArrayAccess, set_error_handler and undefined var) --FILE-- <?php class env { public function __construct() { set_error_handler(array(__CLASS__, 'errorHandler')); } public static function errorHandler($errno, $errstr, $errfile, $errline) { throw new ErrorException($errstr, 0, $errno, $errfile, $errline); } } class cache implements ArrayAccess { private $container = array(); public function offsetGet($id) {} public function offsetSet($id, $value) {} public function offsetUnset($id) {} public function offsetExists($id) { return isset($this->containers[(string) $id]); } } $env = new env(); $cache = new cache(); var_dump(isset($cache[$id])); echo "Done\n"; ?> --EXPECTF-- Fatal error: Uncaught exception 'ErrorException' with message 'Undefined variable: id' in %s:%d Stack trace: #0 %s(%d): env::errorHandler() #1 {main} thrown in %s on line %d

« previous php.zend-engine.cvs (#5752) next »