xref: /PHP-8.0/ext/xmlwriter/tests/bug79029.phpt (revision c5401854)
1--TEST--
2#79029 (Use After Free's in XMLReader / XMLWriter)
3--SKIPIF--
4<?php
5if (!extension_loaded("xmlwriter")) print "skip xmlwriter extension not available";
6if (!extension_loaded("xmlreader")) print "skip xmlreader extension not available";
7?>
8--FILE--
9<?php
10$x = array( new XMLWriter() );
11$x[0]->openUri("bug79029_1.txt");
12$x[0]->startComment();
13
14$y = new XMLWriter();
15$y->openUri("bug79029_2.txt");
16fclose(@end(get_resources()));
17
18file_put_contents("bug79029_3.txt", "a");
19$z = new XMLReader();
20$z->open("bug79029_3.txt");
21fclose(@end(get_resources()));
22?>
23okey
24--CLEAN--
25<?php
26@unlink("bug79029_1.txt");
27@unlink("bug79029_2.txt");
28@unlink("bug79029_3.txt");
29?>
30--EXPECTF--
31Warning: fclose(): %d is not a valid stream resource in %sbug79029.php on line %d
32
33Warning: fclose(): %d is not a valid stream resource in %sbug79029.php on line %d
34okey
35