tony2001                Wed Mar 22 23:12:38 2006 UTC

  Modified files:              
    /php-src/ext/spl    spl_array.c 
    /php-src/ext/spl/tests      bug36825.phpt 
  Log:
  fix leak, add test
  
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_array.c?r1=1.101&r2=1.102&diff_format=u
Index: php-src/ext/spl/spl_array.c
diff -u php-src/ext/spl/spl_array.c:1.101 php-src/ext/spl/spl_array.c:1.102
--- php-src/ext/spl/spl_array.c:1.101   Wed Mar 22 21:57:10 2006
+++ php-src/ext/spl/spl_array.c Wed Mar 22 23:12:38 2006
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_array.c,v 1.101 2006/03/22 21:57:10 tony2001 Exp $ */
+/* $Id: spl_array.c,v 1.102 2006/03/22 23:12:38 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -289,14 +289,13 @@
                if (intern->fptr_offset_get) {
                        zval *rv;
                        zend_call_method_with_1_params(&object, 
Z_OBJCE_P(object), &intern->fptr_offset_get, "offsetGet", &rv, offset); 
-                       zval_ptr_dtor(&intern->retval);
-                       MAKE_STD_ZVAL(intern->retval);
                        if (rv) {
+                               zval_ptr_dtor(&intern->retval);
+                               MAKE_STD_ZVAL(intern->retval);
                                ZVAL_ZVAL(intern->retval, rv, 1, 1);
-                       } else {
-                               ZVAL_NULL(intern->retval);
+                               return intern->retval;
                        }
-                       return intern->retval;
+                       return EG(uninitialized_zval_ptr);
                }
        }
        return *spl_array_get_dimension_ptr_ptr(check_inherited, object, 
offset, type TSRMLS_CC);
http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/tests/bug36825.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/spl/tests/bug36825.phpt
diff -u /dev/null php-src/ext/spl/tests/bug36825.phpt:1.2
--- /dev/null   Wed Mar 22 23:12:38 2006
+++ php-src/ext/spl/tests/bug36825.phpt Wed Mar 22 23:12:38 2006
@@ -0,0 +1,26 @@
+--TEST--
+Bug #36825 ()
+--FILE--
+<?php
+
+class foo extends ArrayObject {
+       public function __construct() {
+       }
+
+       public function offsetGet($key) {
+               throw new Exception("hi");
+       }
+}
+
+$test=new foo();
+try{
+       var_dump($test['bar']);
+} catch (Exception $e) {
+       echo "got exception\n";
+}
+
+echo "Done\n";
+?>
+--EXPECT--     
+got exception
+Done

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to