Annotation of embedaddon/php/ext/curl/tests/curl_file_deleted_before_curl_close.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Memory corruption error if fp of just created file is closed before curl_close.
                      3: --CREDITS--
                      4: Alexey Shein <confik@gmail.com>
                      5: --SKIPIF--
                      6: <?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip"; ?>
                      7: --FILE--
                      8: <?php
                      9: 
                     10: $ch = curl_init(getenv('PHP_CURL_HTTP_REMOTE_SERVER'));
                     11: 
                     12: $temp_file = dirname(__FILE__) . '/curl_file_deleted_before_curl_close.tmp';
                     13: if (file_exists($temp_file)) {
                     14:        unlink($temp_file); // file should not exist before test
                     15: }
                     16: 
                     17: $handle = fopen($temp_file, 'w');
                     18: 
                     19: curl_setopt($ch, CURLOPT_STDERR, $handle);
                     20: curl_setopt($ch, CURLOPT_VERBOSE, 1);
                     21: curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                     22: 
                     23: curl_exec($ch);
                     24: 
                     25: fclose($handle); // causes glibc memory error
                     26: 
                     27: //unlink($temp_file); // uncomment to test segfault (file not found on iowrite.c)
                     28: 
                     29: curl_close($ch);
                     30: echo "Closed correctly\n";
                     31: ?>
                     32: --CLEAN--
                     33: <?php
                     34: unlink(dirname(__FILE__) . '/curl_file_deleted_before_curl_close.tmp');
                     35: ?>
                     36: --EXPECTF--
                     37: * Closing connection #%d
                     38: Closed correctly

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>