From: Nikita Popov Date: Thu, 14 Jul 2016 20:18:06 +0000 (+0200) Subject: Fix leak in PDO row_get_ctor X-Git-Tag: php-7.1.0beta1~52 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9452257b046030c32f1b55b75eadcd711e882ad8;p=php 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. --- diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index b2e7620306..8fe0600b31 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 61f0e49a1c..1bf369b33b 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 7cd1198838..54850d3860 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