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