bug52827.phpt 819 B

1234567891011121314151617181920212223242526272829303132
  1. --TEST--
  2. Bug #52827 (curl_setopt with CURLOPT_STDERR erroneously increments the resource refcount)
  3. --SKIPIF--
  4. <?php
  5. if (!extension_loaded('curl')) {
  6. exit("skip curl extension not loaded");
  7. }
  8. ?>
  9. --FILE--
  10. <?php
  11. $s = fopen('php://temp/maxmemory=1024','wb+');
  12. /* force conversion of inner stream to STDIO.
  13. * This is not necessary in Windows because the
  14. * cast to a FILE* handle in curl_setopt already
  15. * forces the conversion in that platform. The
  16. * reason for this conversion is that the memory
  17. * stream has an ugly but working mechanism to
  18. * prevent being double freed when it's encapsulated,
  19. * while STDIO streams don't. */
  20. $i = 0;
  21. while ($i++ < 5000) {
  22. fwrite($s, str_repeat('a',1024));
  23. }
  24. $handle=curl_init('http://www.example.com');
  25. curl_setopt($handle, CURLOPT_STDERR, $s);
  26. echo "Done.";
  27. --EXPECTF--
  28. Done.