gh8058.phpt 1005 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. --TEST--
  2. GH-8058 (NULL pointer dereference in mysqlnd package (#81706))
  3. --EXTENSIONS--
  4. mysqli
  5. --SKIPIF--
  6. <?php
  7. require_once 'skipifconnectfailure.inc';
  8. ?>
  9. --FILE--
  10. <?php
  11. require_once "connect.inc";
  12. mysqli_report(MYSQLI_REPORT_OFF);
  13. $mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
  14. // There should be no segfault due to NULL deref
  15. $stmt = $mysqli->prepare("select 1,2,3");
  16. $stmt->bind_result($a,$a,$a);
  17. $stmt->prepare("");
  18. $stmt->prepare("select ".str_repeat("'A',", 0x1201)."1");
  19. unset($stmt); // trigger dtor
  20. // There should be no memory leak
  21. $stmt = $mysqli->prepare("select 1,2,3");
  22. $stmt->bind_result($a,$a,$a);
  23. $stmt->prepare("");
  24. $stmt->prepare("select 1");
  25. unset($stmt); // trigger dtor
  26. mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
  27. $stmt = $mysqli->prepare("select 1,2,3");
  28. try {
  29. // We expect an exception to be thrown
  30. $stmt->prepare("");
  31. } catch (mysqli_sql_exception $e) {
  32. var_dump($e->getMessage());
  33. }
  34. ?>
  35. --EXPECT--
  36. string(15) "Query was empty"