com php-src: Fix leak in PDO row_get_ctor: ext/pdo/pdo _stmt.c ext/pdo/tests/pdo_036.phpt ext/pdo/te sts/pdorow.phpt
| From: | Nikita Popov | Date: | Sat, 16 Jul 2016 21:16:26 +0000 |
| Subject: | com php-src: Fix leak in PDO row_get_ctor: ext/pdo/pdo _stmt.c ext/pdo/tests/pdo_036.phpt ext/pdo/te sts/pdorow.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-93047@lists.php.net to get a copy of this message | ||
Commit: 9452257b046030c32f1b55b75eadcd711e882ad8
Author: Nikita Popov <nikic@php.net> Thu, 14 Jul 2016 22:18:06 +0200
Parents: 267c525820a46a45aec05f1963978fdfe1ae291f
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=9452257b046030c32f1b55b75eadcd711e882ad8
Log:
Fix leak in PDO row_get_ctor
The __construct function name was leaked. Avoid this by simply
throwing directly from row_get_ctor instead of indirecting through
an actual __construct function.
Changed paths:
M ext/pdo/pdo_stmt.c
M ext/pdo/tests/pdo_036.phpt
M ext/pdo/tests/pdorow.phpt
Diff:
diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c
index b2e7620..8fe0600 100644
--- a/ext/pdo/pdo_stmt.c
+++ b/ext/pdo/pdo_stmt.c
@@ -113,12 +113,6 @@ ZEND_END_ARG_INFO()
RETURN_FALSE; \
} \
-static PHP_FUNCTION(dbrow_constructor) /* {{{ */
-{
- zend_throw_exception_ex(php_pdo_get_exception(), 0, "You may not create a PDORow
manually");
-}
-/* }}} */
-
static inline int rewrite_name_to_position(pdo_stmt_t *stmt, struct pdo_bound_param_data *param) /*
{{{ */
{
if (stmt->bound_param_map) {
@@ -2638,15 +2632,8 @@ static int row_call_method(zend_string *method, zend_object *object,
INTERNAL_FU
static union _zend_function *row_get_ctor(zend_object *object)
{
- static zend_internal_function ctor = {0};
-
- ctor.type = ZEND_INTERNAL_FUNCTION;
- ctor.function_name = zend_string_init("__construct", sizeof("__construct") -
1, 0);
- ctor.scope = pdo_row_ce;
- ctor.handler = ZEND_FN(dbrow_constructor);
- ctor.fn_flags = ZEND_ACC_PUBLIC;
-
- return (union _zend_function*)&ctor;
+ zend_throw_exception_ex(php_pdo_get_exception(), 0, "You may not create a PDORow
manually");
+ return NULL;
}
static zend_string *row_get_classname(const zend_object *object)
diff --git a/ext/pdo/tests/pdo_036.phpt b/ext/pdo/tests/pdo_036.phpt
index 61f0e49..1bf369b 100644
--- a/ext/pdo/tests/pdo_036.phpt
+++ b/ext/pdo/tests/pdo_036.phpt
@@ -22,7 +22,6 @@ object(PDOStatement)#%d (1) {
Fatal error: Uncaught PDOException: You may not create a PDORow manually in %spdo_036.php:8
Stack trace:
-#0 [internal function]: PDORow->__construct()
-#1 %spdo_036.php(8): ReflectionClass->newInstance()
-#2 {main}
+#0 %spdo_036.php(8): ReflectionClass->newInstance()
+#1 {main}
thrown in %spdo_036.php on line 8
diff --git a/ext/pdo/tests/pdorow.phpt b/ext/pdo/tests/pdorow.phpt
index 7cd1198..54850d3 100644
--- a/ext/pdo/tests/pdorow.phpt
+++ b/ext/pdo/tests/pdorow.phpt
@@ -11,6 +11,5 @@ new PDORow;
--EXPECTF--
Fatal error: Uncaught PDOException: You may not create a PDORow manually in %spdorow.php:3
Stack trace:
-#0 %spdorow.php(3): PDORow->__construct()
-#1 {main}
+#0 {main}
thrown in %spdorow.php on line 3