Skip to content

Commit 7c1705f

Browse files
committed
Fix in_fetch state not being reinitialized
1 parent 6c6826e commit 7c1705f

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

ext/pdo/pdo_stmt.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ static bool do_fetch(pdo_stmt_t *stmt, zval *return_value, enum pdo_fetch_type h
772772
* See ext/pdo/tests/bug_38253.phpt */
773773
if (UNEXPECTED(ce == NULL)) {
774774
pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "No fetch class specified");
775-
return false;
775+
goto in_fetch_error;
776776
}
777777
ctor_arguments = stmt->fetch.cls.ctor_args;
778778
}
@@ -781,7 +781,7 @@ static bool do_fetch(pdo_stmt_t *stmt, zval *return_value, enum pdo_fetch_type h
781781
if (!ce->unserialize) {
782782
/* As this option is deprecated we do not bother to mention the class name. */
783783
pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "cannot unserialize class");
784-
return false;
784+
goto in_fetch_error;
785785
}
786786
} else {
787787
if (UNEXPECTED(object_init_ex(return_value, ce) != SUCCESS)) {
@@ -791,7 +791,7 @@ static bool do_fetch(pdo_stmt_t *stmt, zval *return_value, enum pdo_fetch_type h
791791
bool failed = pdo_call_fetch_object_constructor(ce->constructor, ctor_arguments, return_value);
792792
if (UNEXPECTED(failed)) {
793793
zval_ptr_dtor(return_value);
794-
return false;
794+
goto in_fetch_error;
795795
}
796796
}
797797
}
@@ -803,7 +803,7 @@ static bool do_fetch(pdo_stmt_t *stmt, zval *return_value, enum pdo_fetch_type h
803803
* See ext/pdo/tests/bug_38253.phpt */
804804
if (stmt->fetch.into == NULL) {
805805
pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "No fetch-into object specified.");
806-
return false;
806+
goto in_fetch_error;
807807
}
808808

809809
ZVAL_OBJ_COPY(return_value, stmt->fetch.into);
@@ -819,7 +819,7 @@ static bool do_fetch(pdo_stmt_t *stmt, zval *return_value, enum pdo_fetch_type h
819819
* See ext/pdo/tests/bug_38253.phpt */
820820
if (UNEXPECTED(!ZEND_FCC_INITIALIZED(stmt->fetch.func.fcc))) {
821821
pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "No fetch function specified");
822-
return false;
822+
goto in_fetch_error;
823823
}
824824
/* There will be at most stmt->column_count parameters.
825825
* However, if we fetch a group key we will have over allocated. */
@@ -849,7 +849,7 @@ static bool do_fetch(pdo_stmt_t *stmt, zval *return_value, enum pdo_fetch_type h
849849
if (unserialize_res == FAILURE) {
850850
pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "cannot unserialize class");
851851
zval_ptr_dtor(return_value);
852-
return false;
852+
goto in_fetch_error;
853853
}
854854
column_index_to_fetch++;
855855
}
@@ -929,7 +929,7 @@ static bool do_fetch(pdo_stmt_t *stmt, zval *return_value, enum pdo_fetch_type h
929929
bool failed = pdo_call_fetch_object_constructor(ce->constructor, ctor_arguments, return_value);
930930
if (UNEXPECTED(failed)) {
931931
zval_ptr_dtor(return_value);
932-
return false;
932+
goto in_fetch_error;
933933
}
934934
} else if (how == PDO_FETCH_FUNC) {
935935
zend_call_known_fcc(&stmt->fetch.func.fcc, return_value, fetch_function_param_num, fetch_function_params, NULL);
@@ -942,6 +942,10 @@ static bool do_fetch(pdo_stmt_t *stmt, zval *return_value, enum pdo_fetch_type h
942942
stmt->in_fetch = false;
943943

944944
return true;
945+
946+
in_fetch_error:
947+
stmt->in_fetch = false;
948+
return false;
945949
}
946950
/* }}} */
947951

0 commit comments

Comments
 (0)