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--SKIPIF-- 10<?php 11require_once __DIR__ . '/skipif.inc'; 12require_once __DIR__ . '/skipifconnectfailure.inc'; 13require_once __DIR__ . '/connect.inc'; 14if (!$IS_MYSQLND) { 15 die('skip mysqlnd only'); 16} 17?> 18--FILE-- 19<?php 20 21require_once __DIR__ . '/connect.inc'; 22 23mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); 24 25$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket); 26$stmt = $mysqli->prepare('SELECT 1'); 27 28var_dump( 29 $mysqli->close(), 30 $stmt->free_result(), 31 $stmt->close() 32); 33 34?> 35--EXPECT-- 36bool(true) 37NULL 38bool(true) 39