felipe Mon, 14 Dec 2009 21:44:56 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=292143
Log: - Fixed memory leak when E_STRICT message is getted Changed paths: U php/php-src/branches/PHP_5_3/ext/pdo/pdo_stmt.c A php/php-src/branches/PHP_5_3/ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt U php/php-src/trunk/ext/pdo/pdo_stmt.c A php/php-src/trunk/ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt
Modified: php/php-src/branches/PHP_5_3/ext/pdo/pdo_stmt.c =================================================================== --- php/php-src/branches/PHP_5_3/ext/pdo/pdo_stmt.c 2009-12-14 21:29:08 UTC (rev 292142) +++ php/php-src/branches/PHP_5_3/ext/pdo/pdo_stmt.c 2009-12-14 21:44:56 UTC (rev 292143) @@ -795,6 +795,10 @@ } return 0; } + if (is_callable_error) { + /* Possible E_STRICT error message */ + efree(is_callable_error); + } fci->param_count = num_args; /* probably less */ fci->params = safe_emalloc(sizeof(zval**), num_args, 0); Added: php/php-src/branches/PHP_5_3/ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt (rev 0) +++ php/php-src/branches/PHP_5_3/ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt 2009-12-14 21:44:56 UTC (rev 292143) @@ -0,0 +1,126 @@ +--TEST-- +Testing several callbacks using PDO::FETCH_FUNC +--FILE-- +<?php + +$db = new PDO('sqlite::memory:'); +$db->exec('CREATE TABLE testing (id INTEGER , name VARCHAR)'); +$db->exec('INSERT INTO testing VALUES(1, "php")'); +$db->exec('INSERT INTO testing VALUES(2, "")'); + +$st = $db->query('SELECT * FROM testing'); +$st->fetchAll(PDO::FETCH_FUNC, function($x, $y) use ($st) { var_dump($st); print "data: $x, $y\n"; }); + +$st = $db->query('SELECT name FROM testing'); +var_dump($st->fetchAll(PDO::FETCH_FUNC, 'strtoupper')); + +$st = $db->query('SELECT * FROM testing'); +var_dump($st->fetchAll(PDO::FETCH_FUNC, 'nothing')); + +$st = $db->query('SELECT * FROM testing'); +var_dump($st->fetchAll(PDO::FETCH_FUNC, '')); + +$st = $db->query('SELECT * FROM testing'); +var_dump($st->fetchAll(PDO::FETCH_FUNC, NULL)); + +$st = $db->query('SELECT * FROM testing'); +var_dump($st->fetchAll(PDO::FETCH_FUNC, 1)); + +$st = $db->query('SELECT * FROM testing'); +var_dump($st->fetchAll(PDO::FETCH_FUNC, array('self', 'foo'))); + +class foo { + public function foo($x) { + return "--- $x ---"; + } +} +class bar extends foo { + public function __construct($db) { + $st = $db->query('SELECT * FROM testing'); + var_dump($st->fetchAll(PDO::FETCH_FUNC, array($this, 'parent::foo'))); + } + + static public function test($x, $y) { + return $x .'---'. $y; + } + + private function test2($x, $y) { + return $x; + } + + public function test3($x, $y) { + return $x .'==='. $y; + } +} + +new bar($db); + +$st = $db->query('SELECT * FROM testing'); +var_dump($st->fetchAll(PDO::FETCH_FUNC, array('bar', 'test'))); + +$st = $db->query('SELECT * FROM testing'); +var_dump($st->fetchAll(PDO::FETCH_FUNC, array('bar', 'test2'))); + +$st = $db->query('SELECT * FROM testing'); +var_dump($st->fetchAll(PDO::FETCH_FUNC, array('bar', 'test3'))); + +$st = $db->query('SELECT * FROM testing'); +var_dump($st->fetchAll(PDO::FETCH_FUNC, array('bar', 'inexistent'))); + +?> +--EXPECTF-- +object(PDOStatement)#%d (1) { + [%u|b%"queryString"]=> + %string|unicode%(21) "SELECT * FROM testing" +} +data: 1, php +object(PDOStatement)#%d (1) { + [%u|b%"queryString"]=> + %string|unicode%(21) "SELECT * FROM testing" +} +data: 2, +array(2) { + [0]=> + %string|unicode%(3) "PHP" + [1]=> + %string|unicode%(0) "" +} + +Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: function 'nothing' not found or invalid function name in %s on line %d +bool(false) + +Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: function '' not found or invalid function name in %s on line %d +bool(false) + +Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: no array or string given in %s on line %d +bool(false) + +Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: no array or string given in %s on line %d +bool(false) + +Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: cannot access self:: when no class scope is active in %s on line %d +bool(false) +array(2) { + [0]=> + %string|unicode%(9) "--- 1 ---" + [1]=> + %string|unicode%(9) "--- 2 ---" +} +array(2) { + [0]=> + %string|unicode%(7) "1---php" + [1]=> + %string|unicode%(4) "2---" +} + +Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: cannot access private method bar::test2() in %s on line %d +bool(false) +array(2) { + [0]=> + %string|unicode%(7) "1===php" + [1]=> + %string|unicode%(4) "2===" +} + +Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: class 'bar' does not have a method 'inexistent' in %s on line %d +bool(false) Property changes on: php/php-src/branches/PHP_5_3/ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Added: svn:eol-style + native Modified: php/php-src/trunk/ext/pdo/pdo_stmt.c =================================================================== --- php/php-src/trunk/ext/pdo/pdo_stmt.c 2009-12-14 21:29:08 UTC (rev 292142) +++ php/php-src/trunk/ext/pdo/pdo_stmt.c 2009-12-14 21:44:56 UTC (rev 292143) @@ -794,6 +794,10 @@ } return 0; } + if (is_callable_error) { + /* Possible E_STRICT error message */ + efree(is_callable_error); + } fci->param_count = num_args; /* probably less */ fci->params = safe_emalloc(sizeof(zval**), num_args, 0); Added: php/php-src/trunk/ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt =================================================================== --- php/php-src/trunk/ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt (rev 0) +++ php/php-src/trunk/ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt 2009-12-14 21:44:56 UTC (rev 292143) @@ -0,0 +1,126 @@ +--TEST-- +Testing several callbacks using PDO::FETCH_FUNC +--FILE-- +<?php + +$db = new PDO('sqlite::memory:'); +$db->exec('CREATE TABLE testing (id INTEGER , name VARCHAR)'); +$db->exec('INSERT INTO testing VALUES(1, "php")'); +$db->exec('INSERT INTO testing VALUES(2, "")'); + +$st = $db->query('SELECT * FROM testing'); +$st->fetchAll(PDO::FETCH_FUNC, function($x, $y) use ($st) { var_dump($st); print "data: $x, $y\n"; }); + +$st = $db->query('SELECT name FROM testing'); +var_dump($st->fetchAll(PDO::FETCH_FUNC, 'strtoupper')); + +$st = $db->query('SELECT * FROM testing'); +var_dump($st->fetchAll(PDO::FETCH_FUNC, 'nothing')); + +$st = $db->query('SELECT * FROM testing'); +var_dump($st->fetchAll(PDO::FETCH_FUNC, '')); + +$st = $db->query('SELECT * FROM testing'); +var_dump($st->fetchAll(PDO::FETCH_FUNC, NULL)); + +$st = $db->query('SELECT * FROM testing'); +var_dump($st->fetchAll(PDO::FETCH_FUNC, 1)); + +$st = $db->query('SELECT * FROM testing'); +var_dump($st->fetchAll(PDO::FETCH_FUNC, array('self', 'foo'))); + +class foo { + public function foo($x) { + return "--- $x ---"; + } +} +class bar extends foo { + public function __construct($db) { + $st = $db->query('SELECT * FROM testing'); + var_dump($st->fetchAll(PDO::FETCH_FUNC, array($this, 'parent::foo'))); + } + + static public function test($x, $y) { + return $x .'---'. $y; + } + + private function test2($x, $y) { + return $x; + } + + public function test3($x, $y) { + return $x .'==='. $y; + } +} + +new bar($db); + +$st = $db->query('SELECT * FROM testing'); +var_dump($st->fetchAll(PDO::FETCH_FUNC, array('bar', 'test'))); + +$st = $db->query('SELECT * FROM testing'); +var_dump($st->fetchAll(PDO::FETCH_FUNC, array('bar', 'test2'))); + +$st = $db->query('SELECT * FROM testing'); +var_dump($st->fetchAll(PDO::FETCH_FUNC, array('bar', 'test3'))); + +$st = $db->query('SELECT * FROM testing'); +var_dump($st->fetchAll(PDO::FETCH_FUNC, array('bar', 'inexistent'))); + +?> +--EXPECTF-- +object(PDOStatement)#%d (1) { + [%u|b%"queryString"]=> + %string|unicode%(21) "SELECT * FROM testing" +} +data: 1, php +object(PDOStatement)#%d (1) { + [%u|b%"queryString"]=> + %string|unicode%(21) "SELECT * FROM testing" +} +data: 2, +array(2) { + [0]=> + %string|unicode%(3) "PHP" + [1]=> + %string|unicode%(0) "" +} + +Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: function 'nothing' not found or invalid function name in %s on line %d +bool(false) + +Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: function '' not found or invalid function name in %s on line %d +bool(false) + +Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: no array or string given in %s on line %d +bool(false) + +Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: no array or string given in %s on line %d +bool(false) + +Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: cannot access self:: when no class scope is active in %s on line %d +bool(false) +array(2) { + [0]=> + %string|unicode%(9) "--- 1 ---" + [1]=> + %string|unicode%(9) "--- 2 ---" +} +array(2) { + [0]=> + %string|unicode%(7) "1---php" + [1]=> + %string|unicode%(4) "2---" +} + +Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: cannot access private method bar::test2() in %s on line %d +bool(false) +array(2) { + [0]=> + %string|unicode%(7) "1===php" + [1]=> + %string|unicode%(4) "2===" +} + +Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: class 'bar' does not have a method 'inexistent' in %s on line %d +bool(false) Property changes on: php/php-src/trunk/ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Added: svn:eol-style + native
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php