Skip to content

Commit 89b3439

Browse files
committed
Check ahead of time
1 parent 23d4dc1 commit 89b3439

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

ext/mysqli/mysqli_api.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,10 +1488,12 @@ PHP_FUNCTION(mysqli_stmt_data_seek)
14881488

14891489
MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
14901490

1491-
if (mysql_stmt_data_seek(stmt->stmt, offset)) {
1492-
zend_throw_error(NULL, "The result set buffer is empty");
1491+
if (!stmt->stmt->data || !stmt->stmt->data->result || !stmt->stmt->data->result->stored_data) {
1492+
zend_throw_error(NULL, "No result set associated with the statement");
14931493
RETURN_THROWS();
14941494
}
1495+
1496+
mysql_stmt_data_seek(stmt->stmt, offset);
14951497
}
14961498
/* }}} */
14971499

ext/mysqli/tests/mysqli_stmt_data_seek.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ require_once 'skipifconnectfailure.inc';
8787
?>
8888
--EXPECT--
8989
mysqli_stmt object is not fully initialized
90-
The result set buffer is empty
90+
No result set associated with the statement
9191
int(3)
9292
int(1)
9393
int(1)

0 commit comments

Comments
 (0)