bug45161.phpt 792 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. --TEST--
  2. Bug #45161 (Reusing a curl handle leaks memory)
  3. --EXTENSIONS--
  4. curl
  5. --FILE--
  6. <?php
  7. include 'server.inc';
  8. $host = curl_cli_server_start();
  9. // Fill memory for test
  10. $ch = curl_init();
  11. $fp = fopen(PHP_OS_FAMILY === 'Windows' ? 'nul' : '/dev/null', 'w');
  12. /*
  13. $i = $start = $end = 100000.00;
  14. for ($i = 0; $i < 100; $i++) {
  15. curl_setopt($ch, CURLOPT_URL, 'http://127.0.0.1:9/');
  16. curl_setopt($ch, CURLOPT_FILE, $fp);
  17. curl_exec($ch);
  18. }
  19. */
  20. // Start actual test
  21. $start = memory_get_usage() + 1024;
  22. for($i = 0; $i < 1024; $i++) {
  23. curl_setopt($ch, CURLOPT_URL, "{$host}/get.inc");
  24. curl_setopt($ch, CURLOPT_FILE, $fp);
  25. curl_exec($ch);
  26. }
  27. if ($start < memory_get_usage()) {
  28. echo 'FAIL';
  29. } else {
  30. echo 'PASS';
  31. }
  32. echo "\n";
  33. fclose($fp);
  34. unset($fp);
  35. ?>
  36. --EXPECT--
  37. PASS