xref: /PHP-7.1/ext/simplexml/tests/bug42369.phpt (revision 113213f0)
1--TEST--
2Bug #42369 (Implicit conversion to string leaks memory)
3--SKIPIF--
4<?php if (!extension_loaded('simplexml')) echo 'skip simplexml extension is not loaded'; ?>
5--FILE--
6<?php
7    $xml = '<?xml version="1.0" encoding="utf-8"?>';
8    $x = simplexml_load_string($xml . "<q><x>foo</x></q>");
9
10    echo 'explicit conversion' . PHP_EOL;
11    for ($i = 0; $i < 100000; $i++) {
12        md5(strval($x->x));
13    }
14
15    echo 'no conversion' . PHP_EOL;
16    for ($i = 0; $i < 100000; $i++) {
17        md5($x->x);
18    }
19
20?>
21===DONE===
22--EXPECT--
23explicit conversion
24no conversion
25===DONE===
26