bug69899.phpt 955 B

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