5 changed files with 166 additions and 0 deletions
-
23Zend/tests/temporary_cleaning_001.phpt
-
32Zend/tests/temporary_cleaning_002.phpt
-
19Zend/tests/temporary_cleaning_003.phpt
-
44Zend/tests/temporary_cleaning_004.phpt
-
48Zend/tests/temporary_cleaning_005.phpt
@ -0,0 +1,23 @@ |
|||
--TEST-- |
|||
Temporary leak on exception |
|||
--FILE-- |
|||
<?php |
|||
|
|||
function ops() { |
|||
throw new Exception(); |
|||
} |
|||
|
|||
try { |
|||
$x = 2; |
|||
$y = new stdClass; |
|||
while ($x-- && new stdClass) { |
|||
$r = [$x] + ($y ? ((array) $x) + [2] : ops()); |
|||
$y = (array) $y; |
|||
} |
|||
} catch (Exception $e) { |
|||
} |
|||
|
|||
?> |
|||
==DONE== |
|||
--EXPECT-- |
|||
==DONE== |
|||
@ -0,0 +1,32 @@ |
|||
--TEST-- |
|||
Temporary leak on rope (encapsed string) |
|||
--FILE-- |
|||
<?php |
|||
class Obj { |
|||
function __get($x) { |
|||
throw new Exception(); |
|||
} |
|||
} |
|||
|
|||
$x = new Obj; |
|||
$y = 0; |
|||
|
|||
try { |
|||
$r = "$y|$x->x|"; |
|||
} catch (Exception $e) { |
|||
} |
|||
|
|||
try { |
|||
$r = "$x->x|$y|"; |
|||
} catch (Exception $e) { |
|||
} |
|||
|
|||
try { |
|||
$r = "$y|$y|$x->x"; |
|||
} catch (Exception $e) { |
|||
} |
|||
|
|||
?> |
|||
==DONE== |
|||
--EXPECT-- |
|||
==DONE== |
|||
@ -0,0 +1,19 @@ |
|||
--TEST-- |
|||
Fundamental memory leak test on temporaries |
|||
--FILE-- |
|||
<?php |
|||
|
|||
function ops() { |
|||
throw new Exception(); |
|||
} |
|||
|
|||
try{ |
|||
$x = 1; |
|||
$r = [$x] + ops(); |
|||
} catch (Exception $e) { |
|||
} |
|||
|
|||
?> |
|||
==DONE== |
|||
--EXPECT-- |
|||
==DONE== |
|||
@ -0,0 +1,44 @@ |
|||
--TEST-- |
|||
Temporary leak with switch |
|||
--FILE-- |
|||
<?php |
|||
|
|||
function ops() { |
|||
throw new Exception(); |
|||
} |
|||
|
|||
$a = [new stdClass, new stdClass]; |
|||
switch ($a[0]) { |
|||
case false: |
|||
break; |
|||
default: |
|||
try { |
|||
$x = 2; |
|||
$y = new stdClass; |
|||
while ($x-- && new stdClass) { |
|||
$r = [$x] + ($y ? ((array) $x) + [2] : ops()); |
|||
$y = (array) $y; |
|||
} |
|||
} catch (Exception $e) { |
|||
} |
|||
} |
|||
|
|||
try { |
|||
switch ($a[0]) { |
|||
case false: |
|||
break; |
|||
default: |
|||
$x = 2; |
|||
$y = new stdClass; |
|||
while ($x-- && new stdClass) { |
|||
$r = [$x] + ($y ? ((array) $x) + [2] : ops()); |
|||
$y = (array) $y; |
|||
} |
|||
} |
|||
} catch (Exception $e) { |
|||
} |
|||
|
|||
?> |
|||
==DONE== |
|||
--EXPECT-- |
|||
==DONE== |
|||
@ -0,0 +1,48 @@ |
|||
--TEST-- |
|||
Temporary leak with foreach |
|||
--FILE-- |
|||
<?php |
|||
|
|||
function ops() { |
|||
throw new Exception(); |
|||
} |
|||
|
|||
$a = [new stdClass, new stdClass]; |
|||
foreach ([$a, [new stdClass]] as $b) { |
|||
switch ($b[0]) { |
|||
case false: |
|||
break; |
|||
default: |
|||
try { |
|||
$x = 2; |
|||
$y = new stdClass; |
|||
while ($x-- && new stdClass) { |
|||
$r = [$x] + ($y ? ((array) $x) + [2] : ops()); |
|||
$y = (array) $y; |
|||
} |
|||
} catch (Exception $e) { |
|||
} |
|||
} |
|||
} |
|||
|
|||
foreach ([$a, [new stdClass]] as $b) { |
|||
try { |
|||
switch ($b[0]) { |
|||
case false: |
|||
break; |
|||
default: |
|||
$x = 2; |
|||
$y = new stdClass; |
|||
while ($x-- && new stdClass) { |
|||
$r = [$x] + ($y ? ((array) $x) + [2] : ops()); |
|||
$y = (array) $y; |
|||
} |
|||
} |
|||
} catch (Exception $e) { |
|||
} |
|||
} |
|||
|
|||
?> |
|||
==DONE== |
|||
--EXPECT-- |
|||
==DONE== |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue