tony2001 Wed Oct 11 15:52:56 2006 UTC
Added files: (Branch: PHP_5_2)
/php-src/ext/reflection/tests 008.phpt
Modified files:
/php-src NEWS
/php-src/ext/reflection php_reflection.c
Log:
MFH: fix #39125 (Memleak when reflecting non-existing class/method)
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.301&r2=1.2027.2.547.2.302&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.301 php-src/NEWS:1.2027.2.547.2.302
--- php-src/NEWS:1.2027.2.547.2.301 Wed Oct 11 03:23:51 2006
+++ php-src/NEWS Wed Oct 11 15:52:56 2006
@@ -4,9 +4,10 @@
- Fixed bug #38458, PECL bug #8944, PECL bug #7775 (error retrieving
columns after long/text columns with PDO_ODBC). (Wez)
- Fixed PECL bug #8816 (issue in php_oci_statement_fetch with more than one
+ piecewise column) (jeff at badtz-maru dot com, Tony)
- Fixed PECL bug #7755 (error selecting DOUBLE fields with PDO_ODBC).
("slaws", Wez)
- piecewise column) (jeff at badtz-maru dot com, Tony)
+- Fixed bug #39125 (Memleak when reflecting non-existing class/method). (Tony)
- Fixed bug #39067 (getDeclaringClass() and private properties). (Tony)
- Fixed bug #39034 (curl_exec() with return transfer returns TRUE on empty
files). (Ilia)
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/php_reflection.c?r1=1.164.2.33.2.29&r2=1.164.2.33.2.30&diff_format=u
Index: php-src/ext/reflection/php_reflection.c
diff -u php-src/ext/reflection/php_reflection.c:1.164.2.33.2.29
php-src/ext/reflection/php_reflection.c:1.164.2.33.2.30
--- php-src/ext/reflection/php_reflection.c:1.164.2.33.2.29 Fri Oct 6
18:03:19 2006
+++ php-src/ext/reflection/php_reflection.c Wed Oct 11 15:52:56 2006
@@ -20,7 +20,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_reflection.c,v 1.164.2.33.2.29 2006/10/06 18:03:19 tony2001 Exp $
*/
+/* $Id: php_reflection.c,v 1.164.2.33.2.30 2006/10/11 15:52:56 tony2001 Exp $
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -2165,6 +2165,7 @@
return;
}
if ((tmp = strstr(name_str, "::")) == NULL) {
+ zend_throw_exception_ex(reflection_exception_ptr, 0
TSRMLS_CC, "Invalid method name %s", name_str);
return;
}
classname = &ztmp;
@@ -2186,6 +2187,9 @@
if (zend_lookup_class(Z_STRVAL_P(classname),
Z_STRLEN_P(classname), &pce TSRMLS_CC) == FAILURE) {
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Class %s does not exist",
Z_STRVAL_P(classname));
+ if (classname == &ztmp) {
+ zval_dtor(&ztmp);
+ }
return;
}
ce = *pce;
@@ -2196,6 +2200,9 @@
break;
default:
+ if (classname == &ztmp) {
+ zval_dtor(&ztmp);
+ }
_DO_THROW("The parameter class is expected to be either
a string or an object");
/* returns out of this function */
}
@@ -4844,7 +4851,7 @@
php_info_print_table_start();
php_info_print_table_header(2, "Reflection", "enabled");
- php_info_print_table_row(2, "Version", "$Id: php_reflection.c,v
1.164.2.33.2.29 2006/10/06 18:03:19 tony2001 Exp $");
+ php_info_print_table_row(2, "Version", "$Id: php_reflection.c,v
1.164.2.33.2.30 2006/10/11 15:52:56 tony2001 Exp $");
php_info_print_table_end();
} /* }}} */
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/008.phpt?view=markup&rev=1.1
Index: php-src/ext/reflection/tests/008.phpt
+++ php-src/ext/reflection/tests/008.phpt
--TEST--
ReflectionProperty::getDefaultValue()
--FILE--
<?php
class root
{
public $rPub = "rPub";
public $xPub = "xPub";
protected $rPro = "rPro";
protected $xPro = "xPub";
private $rPri = "rPri";
private $xPri = "xPri";
static public $stat = "rStat";
}
class derived extends root
{
public $dPub = "dPub";
public $xPub = "nPub";
protected $dPro = "dPro";
protected $xPro = "nPub";
private $dPri = "dPri";
private $xPri = "nPri";
}
function show_prop($p)
{
echo "{$p->class}::{$p->name} = " . $p->getDefaultValue() . "\n";
}
function show_class($c)
{
echo "===$c===\n";
$r = new ReflectionClass($c);
foreach($r->getProperties() as $p)
{
show_prop($p);
}
}
show_class("root");
show_class("derived");
?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
===root===
root::rPub = rPub
root::xPub = xPub
root::rPro = rPro
root::xPro = xPub
root::rPri = rPri
root::xPri = xPri
root::stat = rStat
===derived===
derived::dPub = dPub
derived::xPub = nPub
derived::dPro = dPro
derived::xPro = nPub
derived::dPri = dPri
derived::xPri = nPri
derived::rPub = rPub
derived::rPro = rPro
derived::stat = rStat
===DONE===
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php