]> granicus.if.org Git - php/commitdiff
Fix leak in PDO row_get_ctor
authorNikita Popov <nikic@php.net>
Thu, 14 Jul 2016 20:18:06 +0000 (22:18 +0200)
committerNikita Popov <nikic@php.net>
Sat, 16 Jul 2016 21:16:26 +0000 (23:16 +0200)
The __construct function name was leaked. Avoid this by simply
throwing directly from row_get_ctor instead of indirecting through
an actual __construct function.

ext/pdo/pdo_stmt.c
ext/pdo/tests/pdo_036.phpt
ext/pdo/tests/pdorow.phpt

index b2e7620306e5e244c6c5a643425af5f87c2ea007..8fe0600b311cd23b177e11d9ee67621f671495c3 100644 (file)
@@ -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)
index 61f0e49a1c1dc19f5d6d4d45e3ee33887cfb4d18..1bf369b33b7c37aa4aafbfa9cb750fc50e24abb4 100644 (file)
@@ -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
index 7cd11988389dd91ccaaf480da2b7b524f352a6e8..54850d386059d6a951e915b1a1baf2c2fb88f4d6 100644 (file)
@@ -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