xref: /php-src/ext/phar/tests/gh13836.phpt (revision 47bb6c1b)
1--TEST--
2GH-13836 (Renaming a file in a Phar to an already existing filename causes a NULL pointer dereference)
3--EXTENSIONS--
4phar
5--INI--
6phar.require_hash=0
7phar.readonly=0
8--FILE--
9<?php
10$fname = __DIR__ . '/gh13836.phar';
11
12$phar = new Phar($fname, 0, 'a.phar');
13$phar['x'] = 'hi1';
14$phar['y'] = 'hi2';
15
16var_dump(rename("phar://a.phar/x", "phar://a.phar/y"));
17
18var_dump(isset($phar['x']));
19var_dump($phar['y']);
20?>
21--CLEAN--
22<?php
23unlink(__DIR__ . '/gh13836.phar');
24?>
25--EXPECTF--
26bool(true)
27bool(false)
28object(PharFileInfo)#2 (2) {
29  ["pathName":"SplFileInfo":private]=>
30  string(%d) "phar://%sgh13836.phar/y"
31  ["fileName":"SplFileInfo":private]=>
32  string(1) "y"
33}
34