[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/NEWS branches/PHP_5_3/ext/reflection/php_reflection.c branches/PHP_5_3/ext/reflection/tests/bug52057.phpt trunk/ext/reflection/php_reflection.c trunk/ext/

2010-06-11 Thread Felipe Pena
felipe   Fri, 11 Jun 2010 23:37:55 +

Revision: http://svn.php.net/viewvc?view=revision&revision=300393

Log:
- Fixed bug #52057 (ReflectionClass fails on Closure class)

Bug: http://bugs.php.net/52057 (Closed) ReflectionClass fails on Closure class
  
Changed paths:
U   php/php-src/branches/PHP_5_3/NEWS
U   php/php-src/branches/PHP_5_3/ext/reflection/php_reflection.c
A   php/php-src/branches/PHP_5_3/ext/reflection/tests/bug52057.phpt
U   php/php-src/trunk/ext/reflection/php_reflection.c
A   php/php-src/trunk/ext/reflection/tests/bug52057.phpt

Modified: php/php-src/branches/PHP_5_3/NEWS
===
--- php/php-src/branches/PHP_5_3/NEWS   2010-06-11 23:20:13 UTC (rev 300392)
+++ php/php-src/branches/PHP_5_3/NEWS   2010-06-11 23:37:55 UTC (rev 300393)
@@ -73,6 +73,7 @@

 - Fixed bug #52060 (Memory leak when passing a closure to method_exists()).
   (Felipe)
+- Fixed bug #52057 (ReflectionClass fails on Closure class). (Felipe)
 - Fixed bug #52019 (make lcov doesn't support TESTS variable anymore). 
(Patrick)
 - Fixed bug #52010 (open_basedir restrictions mismatch on vacuum command).
   (Ilia)

Modified: php/php-src/branches/PHP_5_3/ext/reflection/php_reflection.c
===
--- php/php-src/branches/PHP_5_3/ext/reflection/php_reflection.c
2010-06-11 23:20:13 UTC (rev 300392)
+++ php/php-src/branches/PHP_5_3/ext/reflection/php_reflection.c
2010-06-11 23:37:55 UTC (rev 300393)
@@ -3384,7 +3384,9 @@

GET_REFLECTION_OBJECT_PTR(ce);
lc_name = zend_str_tolower_dup(name, name_len);
-   if (zend_hash_exists(&ce->function_table, lc_name, name_len + 1)) {
+   if ((ce == zend_ce_closure && (name_len == 
sizeof(ZEND_INVOKE_FUNC_NAME)-1)
+   && memcmp(lc_name, ZEND_INVOKE_FUNC_NAME, 
sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0)
+   || zend_hash_exists(&ce->function_table, lc_name, name_len + 
1)) {
efree(lc_name);
RETURN_TRUE;
} else {
@@ -3401,6 +3403,7 @@
reflection_object *intern;
zend_class_entry *ce;
zend_function *mptr;
+   zval obj_tmp;
char *name, *lc_name;
int name_len;

@@ -3419,6 +3422,14 @@
   method and not the closure definition itself */
reflection_method_factory(ce, mptr, NULL, return_value 
TSRMLS_CC);
efree(lc_name);
+   } else if (ce == zend_ce_closure && !intern->obj && (name_len == 
sizeof(ZEND_INVOKE_FUNC_NAME)-1)
+   && memcmp(lc_name, ZEND_INVOKE_FUNC_NAME, 
sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0
+   && object_init_ex(&obj_tmp, ce) == SUCCESS && (mptr = 
zend_get_closure_invoke_method(&obj_tmp TSRMLS_CC)) != NULL) {
+   /* don't assign closure_object since we only reflect the invoke 
handler
+  method and not the closure definition itself */
+   reflection_method_factory(ce, mptr, NULL, return_value 
TSRMLS_CC);
+   zval_dtor(&obj_tmp);
+   efree(lc_name);
} else if (zend_hash_find(&ce->function_table, lc_name, name_len + 1, 
(void**) &mptr) == SUCCESS) {
reflection_method_factory(ce, mptr, NULL, return_value 
TSRMLS_CC);
efree(lc_name);

Added: php/php-src/branches/PHP_5_3/ext/reflection/tests/bug52057.phpt
===
--- php/php-src/branches/PHP_5_3/ext/reflection/tests/bug52057.phpt 
(rev 0)
+++ php/php-src/branches/PHP_5_3/ext/reflection/tests/bug52057.phpt 
2010-06-11 23:37:55 UTC (rev 300393)
@@ -0,0 +1,54 @@
+--TEST--
+Bug #52057 (ReflectionClass fails on Closure class)
+--FILE--
+hasMethod('__invoke')); // true
+
+$reflection = new ReflectionClass($closure);
+var_dump($reflection->hasMethod('__invoke')); // true
+
+$reflection = new ReflectionObject($closure);
+var_dump($reflection->hasMethod('__invoke')); // true
+
+$reflection = new ReflectionClass('closure');
+var_dump($h = $reflection->getMethod('__invoke')); // true
+var_dump($h->class.'::'.$h->getName());
+
+$reflection = new ReflectionClass($closure);
+var_dump($h = $reflection->getMethod('__invoke')); // true
+var_dump($h->class.'::'.$h->getName());
+
+$reflection = new ReflectionObject($closure);
+var_dump($h = $reflection->getMethod('__invoke')); // true
+var_dump($h->class.'::'.$h->getName());
+
+?>
+--EXPECTF--
+bool(true)
+bool(true)
+bool(true)
+object(ReflectionMethod)#%d (2) {
+  ["name"]=>
+  string(8) "__invoke"
+  ["class"]=>
+  string(7) "Closure"
+}
+string(17) "Closure::__invoke"
+object(ReflectionMethod)#%d (2) {
+  ["name"]=>
+  string(8) "__invoke"
+  ["class"]=>
+  string(7) "Closure"
+}
+string(17) "Closure::__invoke"
+object(ReflectionMethod)#%d (2) {
+  ["name"]=>
+  string(8) "__invoke"
+  ["class"]=>
+  string(7) "Closure"
+}
+string(17)

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/NEWS branches/PHP_5_3/Zend/tests/bug52060.phpt branches/PHP_5_3/Zend/zend_builtin_functions.c trunk/Zend/tests/bug52060.phpt trunk/Zend/zend_builtin_funct

2010-06-11 Thread Felipe Pena
felipe   Fri, 11 Jun 2010 23:20:13 +

Revision: http://svn.php.net/viewvc?view=revision&revision=300392

Log:
- Fixed bug #52060 (Memory leak when passing a closure to method_exists())

Bug: http://bugs.php.net/52060 (Assigned) Memory leak when passing a closure to 
method_exists()
  
Changed paths:
U   php/php-src/branches/PHP_5_3/NEWS
A   php/php-src/branches/PHP_5_3/Zend/tests/bug52060.phpt
U   php/php-src/branches/PHP_5_3/Zend/zend_builtin_functions.c
A   php/php-src/trunk/Zend/tests/bug52060.phpt
U   php/php-src/trunk/Zend/zend_builtin_functions.c

Modified: php/php-src/branches/PHP_5_3/NEWS
===
--- php/php-src/branches/PHP_5_3/NEWS   2010-06-11 23:17:16 UTC (rev 300391)
+++ php/php-src/branches/PHP_5_3/NEWS   2010-06-11 23:20:13 UTC (rev 300392)
@@ -71,6 +71,8 @@
   requests (Fixes CVE-2010-0397, bug #51288). (Raphael Geissert)
 - Fixed 64-bit integer overflow in mhash_keygen_s2k(). (Clément LECIGNE, Stas)

+- Fixed bug #52060 (Memory leak when passing a closure to method_exists()).
+  (Felipe)
 - Fixed bug #52019 (make lcov doesn't support TESTS variable anymore). 
(Patrick)
 - Fixed bug #52010 (open_basedir restrictions mismatch on vacuum command).
   (Ilia)

Added: php/php-src/branches/PHP_5_3/Zend/tests/bug52060.phpt
===
--- php/php-src/branches/PHP_5_3/Zend/tests/bug52060.phpt   
(rev 0)
+++ php/php-src/branches/PHP_5_3/Zend/tests/bug52060.phpt   2010-06-11 
23:20:13 UTC (rev 300392)
@@ -0,0 +1,12 @@
+--TEST--
+Bug #52060 (Memory leak when passing a closure to method_exists())
+--FILE--
+
+--EXPECT--
+bool(true)


Property changes on: php/php-src/branches/PHP_5_3/Zend/tests/bug52060.phpt
___
Added: svn:keywords
   + Id Rev Revision
Added: svn:eol-style
   + native

Modified: php/php-src/branches/PHP_5_3/Zend/zend_builtin_functions.c
===
--- php/php-src/branches/PHP_5_3/Zend/zend_builtin_functions.c  2010-06-11 
23:17:16 UTC (rev 300391)
+++ php/php-src/branches/PHP_5_3/Zend/zend_builtin_functions.c  2010-06-11 
23:20:13 UTC (rev 300392)
@@ -26,6 +26,7 @@
 #include "zend_ini.h"
 #include "zend_exceptions.h"
 #include "zend_extensions.h"
+#include "zend_closures.h"

 #undef ZEND_TEST_EXCEPTIONS

@@ -1098,22 +1099,29 @@
RETURN_TRUE;
} else {
union _zend_function *func = NULL;
-   efree(lcname);

if (Z_TYPE_P(klass) == IS_OBJECT
&& Z_OBJ_HT_P(klass)->get_method != NULL
&& (func = Z_OBJ_HT_P(klass)->get_method(&klass, method_name, 
method_len TSRMLS_CC)) != NULL
) {
if (func->type == ZEND_INTERNAL_FUNCTION
-   && ((zend_internal_function*)func)->handler == 
zend_std_call_user_call
+   && (func->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) 
!= 0
) {
+   /* Returns true to the fake Closure's __invoke 
*/
+   RETVAL_BOOL((func->common.scope == 
zend_ce_closure
+   && (method_len == 
sizeof(ZEND_INVOKE_FUNC_NAME)-1)
+   && memcmp(lcname, 
ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0) ? 1 : 0);
+
+   efree(lcname);

efree(((zend_internal_function*)func)->function_name);
efree(func);
-   RETURN_FALSE;
+   return;
}
+   efree(lcname);
RETURN_TRUE;
}
}
+   efree(lcname);
RETURN_FALSE;
 }
 /* }}} */

Added: php/php-src/trunk/Zend/tests/bug52060.phpt
===
--- php/php-src/trunk/Zend/tests/bug52060.phpt  (rev 0)
+++ php/php-src/trunk/Zend/tests/bug52060.phpt  2010-06-11 23:20:13 UTC (rev 
300392)
@@ -0,0 +1,12 @@
+--TEST--
+Bug #52060 (Memory leak when passing a closure to method_exists())
+--FILE--
+
+--EXPECT--
+bool(true)


Property changes on: php/php-src/trunk/Zend/tests/bug52060.phpt
___
Added: svn:keywords
   + Id Rev Revision
Added: svn:eol-style
   + native

Modified: php/php-src/trunk/Zend/zend_builtin_functions.c
===
--- php/php-src/trunk/Zend/zend_builtin_functions.c 2010-06-11 23:17:16 UTC 
(rev 300391)
+++ php/php-src/trunk/Zend/zend_builtin_functions.c 2010-06-11 23:20:13 UTC 
(rev 300392)
@@ -26,6 +26,7 @@
 #include "zend_ini.h"
 #include "zend_exc

[PHP-CVS] svn: /SVNROOT/ global_avail

2010-06-11 Thread Derick Rethans
derick   Fri, 11 Jun 2010 13:51:43 +

Revision: http://svn.php.net/viewvc?view=revision&revision=300383

Log:
- Upgrade Patrick.

Changed paths:
U   SVNROOT/global_avail

Modified: SVNROOT/global_avail
===
--- SVNROOT/global_avail2010-06-11 13:44:31 UTC (rev 300382)
+++ SVNROOT/global_avail2010-06-11 13:51:43 UTC (rev 300383)
@@ -16,7 +16,7 @@
 # The PHP Developers have full access to the full source trees for
 # PHP, as well as the documentation.

-avail|mgdm,pierrick,ilewis,mkoppanen,lstrojny,dharmap,kraghuba,stevseea,colder,lwe,auroraeosrose,mike,rolland,cawa,msisolak,alan_k,rrichards,tal,mfischer,fmk,hirokawa,jah,eschmid,dbeu,sebastian,samjam,avsm,ronabob,derick,sterling,venaas,stas,hholzgra,cmv,phildriscoll,jmoore,andre,jani,sr,david,jdonagher,chagenbu,jon,elixer,joosters,jason,mysql,kalowsky,opaquedave,steinm,phanto,gluke,svanegmond,rjs,vlad,jimjag,emile,wez,sasha,camber,ohrn,romolo,martin,lurcher,wsanchez,dreid,bmcadams,swm,zhang,kevin,joey,entity,cardinal,coar,jflemer,raphael,danda,rbb,mboeren,dougm,edink,alexwaugh,bernd,zak,sesser,yohgaki,imajes,markonen,dickmeiss,helly,sander,jan,kir,aaron,jwoolley,pbannister,rvenkat,dali,rodif_bl,hyanantha,witten,georg,msopacua,mpdoremus,fujimoto,iliaa,chregu,azzit,gschlossnagle,andrey,dan,moriyoshi,dviner,bfrance,flex,iwakiri,john,harrie,pollita,ianh,k.schroeder,dcowgill,jerenkrantz,jay,ddhill,jorton,thetaphi,abies,vincent,goba,dmitry,pajoye,shie,rafi,magnus,tony2001,johann!
 
es,dbs,skoduru,nrathna,jesus,gopalv,bjori,nlopess,wrowe,shire,zoe,scottmac,t2man,dsp,davidw,ab5602,nicholsr,lsmith,cellog,davidc,felipe,robinf,jmessa,philip,sixd,gwynne,ant,kalle,mattwil,sfox,hnangelo,ohill,indeyets,felixdv,mich4ld,lbarnaud,cseiler,sean,dkelsey,tabe,ericstewart,mbeccati,sebs,garretts,guenter,srinatar,basantk,geissert,salathe,aharvey,mj,gron|php/php-src,pecl,phpdoc,phd,web/doc,web/doc-editor
+avail|patrickallaert,mgdm,pierrick,ilewis,mkoppanen,lstrojny,dharmap,kraghuba,stevseea,colder,lwe,auroraeosrose,mike,rolland,cawa,msisolak,alan_k,rrichards,tal,mfischer,fmk,hirokawa,jah,eschmid,dbeu,sebastian,samjam,avsm,ronabob,derick,sterling,venaas,stas,hholzgra,cmv,phildriscoll,jmoore,andre,jani,sr,david,jdonagher,chagenbu,jon,elixer,joosters,jason,mysql,kalowsky,opaquedave,steinm,phanto,gluke,svanegmond,rjs,vlad,jimjag,emile,wez,sasha,camber,ohrn,romolo,martin,lurcher,wsanchez,dreid,bmcadams,swm,zhang,kevin,joey,entity,cardinal,coar,jflemer,raphael,danda,rbb,mboeren,dougm,edink,alexwaugh,bernd,zak,sesser,yohgaki,imajes,markonen,dickmeiss,helly,sander,jan,kir,aaron,jwoolley,pbannister,rvenkat,dali,rodif_bl,hyanantha,witten,georg,msopacua,mpdoremus,fujimoto,iliaa,chregu,azzit,gschlossnagle,andrey,dan,moriyoshi,dviner,bfrance,flex,iwakiri,john,harrie,pollita,ianh,k.schroeder,dcowgill,jerenkrantz,jay,ddhill,jorton,thetaphi,abies,vincent,goba,dmitry,pajoye,shie,rafi,magnus,!
 
tony2001,johannes,dbs,skoduru,nrathna,jesus,gopalv,bjori,nlopess,wrowe,shire,zoe,scottmac,t2man,dsp,davidw,ab5602,nicholsr,lsmith,cellog,davidc,felipe,robinf,jmessa,philip,sixd,gwynne,ant,kalle,mattwil,sfox,hnangelo,ohill,indeyets,felixdv,mich4ld,lbarnaud,cseiler,sean,dkelsey,tabe,ericstewart,mbeccati,sebs,garretts,guenter,srinatar,basantk,geissert,salathe,aharvey,mj,gron|php/php-src,pecl,phpdoc,phd,web/doc,web/doc-editor

 # Engine karma is further restricted (this line MUST come after lines granting
 # php-src karma and before lines granting Zend/TSRM karma)
@@ -310,7 +310,6 @@
 avail|jluedke|pecl/drizzle
 avail|vito,mkoppanen|pecl/gmagick
 avail|santiago|pecl/gupnp,pecl/sphinx
-avail|patrickallaert|php/php-src/*/ext/ldap,php/php-src/*/tests,php/php-src/*/NEWS
 avail|basantk|pecl/memsession
 avail|devour|pecl/geoip
 avail|iekpo|pecl/solr,phpdoc

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

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_2/NEWS branches/PHP_5_2/ext/standard/array.c branches/PHP_5_2/ext/standard/tests/array/bug51552.phpt branches/PHP_5_3/ext/standard/array.c branches/PHP_5_3/

2010-06-11 Thread Dmitry Stogov
dmitry   Fri, 11 Jun 2010 08:53:31 +

Revision: http://svn.php.net/viewvc?view=revision&revision=300371

Log:
Fixed bug #51552 (debug_backtrace() causes segmentation fault and/or memory 
issues)

Bug: http://bugs.php.net/51552 (Assigned) debug_backtrace() causes segmentation 
fault and/or memory issues
  
Changed paths:
U   php/php-src/branches/PHP_5_2/NEWS
U   php/php-src/branches/PHP_5_2/ext/standard/array.c
A   php/php-src/branches/PHP_5_2/ext/standard/tests/array/bug51552.phpt
U   php/php-src/branches/PHP_5_3/ext/standard/array.c
A   php/php-src/branches/PHP_5_3/ext/standard/tests/array/bug51552.phpt
U   php/php-src/trunk/ext/standard/array.c
A   php/php-src/trunk/ext/standard/tests/array/bug51552.phpt

Modified: php/php-src/branches/PHP_5_2/NEWS
===
--- php/php-src/branches/PHP_5_2/NEWS   2010-06-11 06:41:34 UTC (rev 300370)
+++ php/php-src/branches/PHP_5_2/NEWS   2010-06-11 08:53:31 UTC (rev 300371)
@@ -43,6 +43,8 @@
   (Daniel Egeberg)
 - Fixed bug #51562 (query timeout in mssql can not be changed per query).
   (ejsmont dot artur at gmail dot com)
+- Fixed bug #51552 (debug_backtrace() causes segmentation fault and/or memory
+  issues). (Dmitry)
 - Fixed bug #51532 (Wrong prototype for SplFileObject::fscanf()). (Etienne)
 - Fixed bug #51445 (var_dump() invalid/slow *RECURSION* detection). (Felipe)
 - Fixed bug #51393 (DateTime::createFromFormat() fails if format string 
contains

Modified: php/php-src/branches/PHP_5_2/ext/standard/array.c
===
--- php/php-src/branches/PHP_5_2/ext/standard/array.c   2010-06-11 06:41:34 UTC 
(rev 300370)
+++ php/php-src/branches/PHP_5_2/ext/standard/array.c   2010-06-11 08:53:31 UTC 
(rev 300371)
@@ -1163,6 +1163,9 @@
/* Set up known arguments */
args[1] = &key;
args[2] = userdata;
+   if (userdata) {
+   (*userdata)->refcount++;
+   }

zend_hash_internal_pointer_reset_ex(target_hash, &pos);

@@ -1175,6 +1178,9 @@
thash = HASH_OF(*(args[0]));
if (thash->nApplyCount > 1) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, 
"recursion detected");
+   if (userdata) {
+   zval_ptr_dtor(userdata);
+   }
return 0;
}
thash->nApplyCount++;
@@ -1233,6 +1239,9 @@
zend_hash_move_forward_ex(target_hash, &pos);
}

+   if (userdata) {
+   zval_ptr_dtor(userdata);
+   }
return 0;
 }
 /* }}} */

Added: php/php-src/branches/PHP_5_2/ext/standard/tests/array/bug51552.phpt
===
--- php/php-src/branches/PHP_5_2/ext/standard/tests/array/bug51552.phpt 
(rev 0)
+++ php/php-src/branches/PHP_5_2/ext/standard/tests/array/bug51552.phpt 
2010-06-11 08:53:31 UTC (rev 300371)
@@ -0,0 +1,23 @@
+--TEST--
+Bug #51552 (debug_backtrace() causes segmentation fault and/or memory issues)
+--FILE--
+
+--EXPECT--
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10

Modified: php/php-src/branches/PHP_5_3/ext/standard/array.c
===
--- php/php-src/branches/PHP_5_3/ext/standard/array.c   2010-06-11 06:41:34 UTC 
(rev 300370)
+++ php/php-src/branches/PHP_5_3/ext/standard/array.c   2010-06-11 08:53:31 UTC 
(rev 300371)
@@ -1057,6 +1057,9 @@
/* Set up known arguments */
args[1] = &key;
args[2] = userdata;
+   if (userdata) {
+   Z_ADDREF_PP(userdata);
+   }

zend_hash_internal_pointer_reset_ex(target_hash, &pos);

@@ -1076,6 +1079,9 @@
thash = Z_ARRVAL_PP(args[0]);
if (thash->nApplyCount > 1) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, 
"recursion detected");
+   if (userdata) {
+   zval_ptr_dtor(userdata);
+   }
return 0;
}

@@ -1126,6 +1132,9 @@
zend_hash_move_forward_ex(target_hash, &pos);
}

+   if (userdata) {
+   zval_ptr_dtor(userdata);
+   }
return 0;
 }
 /* }}} */

Added: php/php-src/branches/PHP_5_3/ext/standard/tests/array/bug51552.phpt
===
--- php/php-src/branches/PHP_5_3/ext/standard/tests/array/bug51552.phpt 
(rev 0)
+++ php/php-src/branches/PHP_5_3/ext/standard/tests/array/bug51552.phpt 
2010-06-11 08:53:31 UTC (rev 300371)
@@ -0,0 +1,23 @@
+--TEST--
+Bug #51552 (debug_backtrace() causes segmentation fault and/or memory issu