1--TEST-- 2Bug #69899: Segfault on stmt close after free_result with mysqlnd. 3--DESCRIPTION-- 4The segfault happens only if the database connection was already closed and 5free_result is called on a prepared statement followed by closing that 6statement. This is due to mysqlnd_stmt::free_result (mysqlnd_ps.c) which 7unconditionally sets the connection of the statement to ready, despite the fact 8that it might already be closed. 9--EXTENSIONS-- 10mysqli 11--SKIPIF-- 12<?php 13require_once __DIR__ . '/skipifconnectfailure.inc'; 14?> 15--FILE-- 16<?php 17 18require_once __DIR__ . '/connect.inc'; 19 20mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); 21 22$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket); 23$stmt = $mysqli->prepare('SELECT 1'); 24 25var_dump( 26 $mysqli->close(), 27 $stmt->free_result(), 28 $stmt->close() 29); 30 31?> 32--EXPECT-- 33bool(true) 34NULL 35bool(true) 36