Skip to content

Commit 9c66a1e

Browse files
committed
Fix bad refactoring
1 parent 3a1d084 commit 9c66a1e

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

ext/pdo/pdo_stmt.c

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,6 @@ static bool do_fetch(pdo_stmt_t *stmt, zval *return_value, enum pdo_fetch_type h
789789
bool failed = pdo_call_fetch_object_constructor(ce->constructor, ctor_arguments, return_value);
790790
if (UNEXPECTED(failed)) {
791791
zval_ptr_dtor(return_value);
792-
RETVAL_FALSE;
793792
return false;
794793
}
795794
}
@@ -807,9 +806,6 @@ static bool do_fetch(pdo_stmt_t *stmt, zval *return_value, enum pdo_fetch_type h
807806

808807
ZVAL_OBJ_COPY(return_value, stmt->fetch.into);
809808

810-
if (Z_OBJ_P(return_value)->ce == ZEND_STANDARD_CLASS_DEF_PTR) {
811-
how = PDO_FETCH_OBJ;
812-
}
813809
/* We want the behaviour of fetching into an object to be called from the global scope rather
814810
* than the object scope */
815811
ce = NULL;
@@ -850,6 +846,7 @@ static bool do_fetch(pdo_stmt_t *stmt, zval *return_value, enum pdo_fetch_type h
850846
zval_ptr_dtor(&unserialization_string);
851847
if (unserialize_res == FAILURE) {
852848
pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "cannot unserialize class");
849+
zval_ptr_dtor(return_value);
853850
return false;
854851
}
855852
column_index_to_fetch++;
@@ -929,6 +926,7 @@ static bool do_fetch(pdo_stmt_t *stmt, zval *return_value, enum pdo_fetch_type h
929926
if (how == PDO_FETCH_CLASS && ce->constructor && !(flags & (PDO_FETCH_PROPS_LATE | PDO_FETCH_SERIALIZE))) {
930927
bool failed = pdo_call_fetch_object_constructor(ce->constructor, ctor_arguments, return_value);
931928
if (UNEXPECTED(failed)) {
929+
zval_ptr_dtor(return_value);
932930
return false;
933931
}
934932
} else if (how == PDO_FETCH_FUNC) {
@@ -1036,7 +1034,6 @@ PHP_METHOD(PDOStatement, fetch)
10361034
return;
10371035
}
10381036
if (!do_fetch(stmt, return_value, how, ori, off, NULL)) {
1039-
zval_ptr_dtor(return_value);
10401037
PDO_HANDLE_STMT_ERR();
10411038
RETURN_FALSE;
10421039
}
@@ -1074,7 +1071,6 @@ PHP_METHOD(PDOStatement, fetchObject)
10741071
stmt->fetch.cls.ctor_args = ctor_args;
10751072

10761073
if (!do_fetch(stmt, return_value, PDO_FETCH_CLASS, PDO_FETCH_ORI_NEXT, /* offset */ 0, NULL)) {
1077-
zval_ptr_dtor(return_value);
10781074
PDO_HANDLE_STMT_ERR();
10791075
RETVAL_FALSE;
10801076
}
@@ -1247,14 +1243,8 @@ PHP_METHOD(PDOStatement, fetchAll)
12471243

12481244
if (fetch_mode == PDO_FETCH_KEY_PAIR) {
12491245
while (pdo_do_key_pair_fetch(stmt, PDO_FETCH_ORI_NEXT, /* offset */ 0, Z_ARRVAL_P(return_value)));
1250-
/* Inline PDO_HANDLE_STMT_ERR(); as we need to free the return value */
1251-
if (UNEXPECTED(EG(exception) || strcmp(stmt->error_code, PDO_ERR_NONE) != 0)) {
1252-
zval_ptr_dtor(return_value);
1253-
if (strcmp(stmt->error_code, PDO_ERR_NONE) != 0) {
1254-
pdo_handle_error(stmt->dbh, stmt);
1255-
}
1256-
RETURN_EMPTY_ARRAY();
1257-
}
1246+
PDO_HANDLE_STMT_ERR();
1247+
return;
12581248
}
12591249

12601250
// Need to handle the "broken" PDO_FETCH_GROUP|PDO_FETCH_UNIQUE fetch case
@@ -1288,7 +1278,6 @@ PHP_METHOD(PDOStatement, fetchAll)
12881278

12891279
/* Inline PDO_HANDLE_STMT_ERR(); as we need to free the return value */
12901280
if (UNEXPECTED(EG(exception) || strcmp(stmt->error_code, PDO_ERR_NONE) != 0)) {
1291-
zval_ptr_dtor(&data);
12921281
zval_ptr_dtor(return_value);
12931282
if (strcmp(stmt->error_code, PDO_ERR_NONE) != 0) {
12941283
pdo_handle_error(stmt->dbh, stmt);

0 commit comments

Comments
 (0)