xref: /PHP-5.5/ext/zip/tests/bug53579.phpt (revision 3ce18aa8)
1--TEST--
2Bug #53579 (stream_get_contents() segfaults on ziparchive streams)
3--SKIPIF--
4<?php
5/* $Id: oo_stream.phpt 260091 2008-05-21 09:27:41Z pajoye $ */
6if(!extension_loaded('zip')) die('skip');
7?>
8--FILE--
9<?php
10$dirname = dirname(__FILE__) . '/';
11$file = $dirname . 'test_with_comment.zip';
12include $dirname . 'utils.inc';
13$zip = new ZipArchive;
14if (!$zip->open($file)) {
15	exit('failed');
16}
17$fp = $zip->getStream('foo');
18
19var_dump($fp);
20if(!$fp) exit("\n");
21$contents = stream_get_contents($fp);
22
23fclose($fp);
24$zip->close();
25var_dump($contents);
26
27
28$fp = fopen('zip://' . dirname(__FILE__) . '/test_with_comment.zip#foo', 'rb');
29if (!$fp) {
30  exit("cannot open\n");
31}
32$contents = stream_get_contents($fp);
33var_dump($contents);
34fclose($fp);
35
36?>
37--EXPECTF--
38resource(%d) of type (stream)
39string(5) "foo
40
41"
42string(5) "foo
43
44"
45