@@ -836,14 +836,14 @@ static bool do_fetch(pdo_stmt_t *stmt, zval *return_value, enum pdo_fetch_type h
836
836
837
837
case PDO_FETCH_INTO :
838
838
/* TODO: Make this an assertion and ensure this is true higher up? */
839
- if (Z_ISUNDEF ( stmt -> fetch .into ) ) {
839
+ if (stmt -> fetch .into == NULL ) {
840
840
/* TODO ArgumentCountError? */
841
841
pdo_raise_impl_error (stmt -> dbh , stmt , "HY000" , "No fetch-into object specified." );
842
842
return 0 ;
843
843
break ;
844
844
}
845
845
846
- ZVAL_COPY (return_value , & stmt -> fetch .into );
846
+ ZVAL_OBJ_COPY (return_value , stmt -> fetch .into );
847
847
848
848
if (Z_OBJ_P (return_value )-> ce == ZEND_STANDARD_CLASS_DEF_PTR ) {
849
849
how = PDO_FETCH_OBJ ;
@@ -1655,9 +1655,9 @@ bool pdo_stmt_setup_fetch_mode(pdo_stmt_t *stmt, zend_long mode, uint32_t mode_a
1655
1655
1656
1656
switch (stmt -> default_fetch_type ) {
1657
1657
case PDO_FETCH_INTO :
1658
- if (! Z_ISUNDEF ( stmt -> fetch .into ) ) {
1659
- zval_ptr_dtor ( & stmt -> fetch .into );
1660
- ZVAL_UNDEF ( & stmt -> fetch .into ) ;
1658
+ if (stmt -> fetch .into ) {
1659
+ OBJ_RELEASE ( stmt -> fetch .into );
1660
+ stmt -> fetch .into = NULL ;
1661
1661
}
1662
1662
break ;
1663
1663
default :
@@ -1786,7 +1786,8 @@ bool pdo_stmt_setup_fetch_mode(pdo_stmt_t *stmt, zend_long mode, uint32_t mode_a
1786
1786
return false;
1787
1787
}
1788
1788
1789
- ZVAL_COPY (& stmt -> fetch .into , & args [0 ]);
1789
+ GC_TRY_ADDREF (Z_OBJ (args [0 ]));
1790
+ stmt -> fetch .into = Z_OBJ (args [0 ]);
1790
1791
break ;
1791
1792
default :
1792
1793
zend_argument_value_error (mode_arg_num , "must be one of the PDO::FETCH_* constants" );
@@ -2027,8 +2028,15 @@ static zend_function *dbstmt_method_get(zend_object **object_pp, zend_string *me
2027
2028
static HashTable * dbstmt_get_gc (zend_object * object , zval * * gc_data , int * gc_count )
2028
2029
{
2029
2030
pdo_stmt_t * stmt = php_pdo_stmt_fetch_object (object );
2030
- * gc_data = & stmt -> fetch .into ;
2031
- * gc_count = 1 ;
2031
+
2032
+ if (stmt -> default_fetch_type & PDO_FETCH_INTO ) {
2033
+ zend_get_gc_buffer * gc_buffer = zend_get_gc_buffer_create ();
2034
+ zend_get_gc_buffer_add_obj (gc_buffer , stmt -> fetch .into );
2035
+ zend_get_gc_buffer_use (gc_buffer , gc_data , gc_count );
2036
+ } else {
2037
+ * gc_data = NULL ;
2038
+ * gc_count = 0 ;
2039
+ }
2032
2040
2033
2041
/**
2034
2042
* If there are no dynamic properties and the default property is 1 (that is, there is only one property
@@ -2074,9 +2082,9 @@ PDO_API void php_pdo_free_statement(pdo_stmt_t *stmt)
2074
2082
2075
2083
pdo_stmt_reset_columns (stmt );
2076
2084
2077
- if (! Z_ISUNDEF ( stmt -> fetch .into ) && stmt -> default_fetch_type == PDO_FETCH_INTO ) {
2078
- zval_ptr_dtor ( & stmt -> fetch .into );
2079
- ZVAL_UNDEF ( & stmt -> fetch .into ) ;
2085
+ if (stmt -> fetch .into && stmt -> default_fetch_type == PDO_FETCH_INTO ) {
2086
+ OBJ_RELEASE ( stmt -> fetch .into );
2087
+ stmt -> fetch .into = NULL ;
2080
2088
}
2081
2089
2082
2090
do_fetch_opt_finish (stmt , 1 );
@@ -2165,7 +2173,6 @@ static void pdo_stmt_iter_move_forwards(zend_object_iterator *iter)
2165
2173
2166
2174
if (!do_fetch (stmt , & I -> fetch_ahead , PDO_FETCH_USE_DEFAULT ,
2167
2175
PDO_FETCH_ORI_NEXT , /* offset */ 0 , NULL )) {
2168
-
2169
2176
PDO_HANDLE_STMT_ERR ();
2170
2177
I -> key = (zend_ulong )- 1 ;
2171
2178
ZVAL_UNDEF (& I -> fetch_ahead );
0 commit comments