mirror of
https://github.com/php/php-src.git
synced 2024-12-02 22:34:55 +08:00
c48b745f00
This implements the last remaining part of the https://wiki.php.net/rfc/engine_warnings RFC. Closes GH-5927.
94 lines
1.9 KiB
PHP
94 lines
1.9 KiB
PHP
--TEST--
|
|
Bug #52041 (Memory leak when writing on uninitialized variable returned from function)
|
|
--FILE--
|
|
<?php
|
|
function foo() {
|
|
return $x;
|
|
}
|
|
|
|
try {
|
|
foo()->a = 1;
|
|
} catch (Error $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
try {
|
|
foo()->a->b = 2;
|
|
} catch (Error $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
try {
|
|
foo()->a++;
|
|
} catch (Error $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
try {
|
|
foo()->a->b++;
|
|
} catch (Error $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
try {
|
|
foo()->a += 2;
|
|
} catch (Error $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
try {
|
|
foo()->a->b += 2;
|
|
} catch (Error $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
|
|
foo()[0] = 1;
|
|
foo()[0][0] = 2;
|
|
foo()[0]++;
|
|
foo()[0][0]++;
|
|
foo()[0] += 2;
|
|
foo()[0][0] += 2;
|
|
|
|
var_dump(foo());
|
|
?>
|
|
--EXPECTF--
|
|
Warning: Undefined variable $x in %s on line %d
|
|
Attempt to assign property "a" on null
|
|
|
|
Warning: Undefined variable $x in %s on line %d
|
|
Attempt to modify property "a" on null
|
|
|
|
Warning: Undefined variable $x in %s on line %d
|
|
Attempt to increment/decrement property "a" on null
|
|
|
|
Warning: Undefined variable $x in %s on line %d
|
|
Attempt to modify property "a" on null
|
|
|
|
Warning: Undefined variable $x in %s on line %d
|
|
Attempt to assign property "a" on null
|
|
|
|
Warning: Undefined variable $x in %s on line %d
|
|
Attempt to modify property "a" on null
|
|
|
|
Warning: Undefined variable $x in %s on line %d
|
|
|
|
Warning: Undefined variable $x in %s on line %d
|
|
|
|
Warning: Undefined variable $x in %s on line %d
|
|
|
|
Warning: Undefined array key 0 in %s on line %d
|
|
|
|
Warning: Undefined variable $x in %s on line %d
|
|
|
|
Warning: Undefined array key 0 in %s on line %d
|
|
|
|
Warning: Undefined array key 0 in %s on line %d
|
|
|
|
Warning: Undefined variable $x in %s on line %d
|
|
|
|
Warning: Undefined array key 0 in %s on line %d
|
|
|
|
Warning: Undefined variable $x in %s on line %d
|
|
|
|
Warning: Undefined array key 0 in %s on line %d
|
|
|
|
Warning: Undefined array key 0 in %s on line %d
|
|
|
|
Warning: Undefined variable $x in %s on line %d
|
|
NULL
|