Skip to content

Commit 23d4dc1

Browse files
committed
Throw error when mysql_stmt_data_seek fails
1 parent f63be32 commit 23d4dc1

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

ext/mysqli/mysqli_api.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1488,7 +1488,10 @@ PHP_FUNCTION(mysqli_stmt_data_seek)
14881488

14891489
MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
14901490

1491-
mysql_stmt_data_seek(stmt->stmt, offset);
1491+
if (mysql_stmt_data_seek(stmt->stmt, offset)) {
1492+
zend_throw_error(NULL, "The result set buffer is empty");
1493+
RETURN_THROWS();
1494+
}
14921495
}
14931496
/* }}} */
14941497

ext/mysqli/tests/mysqli_stmt_data_seek.phpt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ require_once 'skipifconnectfailure.inc';
2525
if (true !== ($tmp = mysqli_stmt_execute($stmt)))
2626
printf("[006] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
2727

28+
try {
29+
mysqli_stmt_data_seek($stmt, 1);
30+
} catch (Error $exception) {
31+
echo $exception->getMessage() . "\n";
32+
}
2833

2934
$id = null;
3035
if (!mysqli_stmt_bind_result($stmt, $id))
@@ -82,6 +87,7 @@ require_once 'skipifconnectfailure.inc';
8287
?>
8388
--EXPECT--
8489
mysqli_stmt object is not fully initialized
90+
The result set buffer is empty
8591
int(3)
8692
int(1)
8793
int(1)

0 commit comments

Comments
 (0)