bug52041.phpt 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. --TEST--
  2. Bug #52041 (Memory leak when writing on uninitialized variable returned from function)
  3. --FILE--
  4. <?php
  5. function foo() {
  6. return $x;
  7. }
  8. try {
  9. foo()->a = 1;
  10. } catch (Error $e) {
  11. echo $e->getMessage(), "\n";
  12. }
  13. try {
  14. foo()->a->b = 2;
  15. } catch (Error $e) {
  16. echo $e->getMessage(), "\n";
  17. }
  18. try {
  19. foo()->a++;
  20. } catch (Error $e) {
  21. echo $e->getMessage(), "\n";
  22. }
  23. try {
  24. foo()->a->b++;
  25. } catch (Error $e) {
  26. echo $e->getMessage(), "\n";
  27. }
  28. try {
  29. foo()->a += 2;
  30. } catch (Error $e) {
  31. echo $e->getMessage(), "\n";
  32. }
  33. try {
  34. foo()->a->b += 2;
  35. } catch (Error $e) {
  36. echo $e->getMessage(), "\n";
  37. }
  38. foo()[0] = 1;
  39. foo()[0][0] = 2;
  40. foo()[0]++;
  41. foo()[0][0]++;
  42. foo()[0] += 2;
  43. foo()[0][0] += 2;
  44. var_dump(foo());
  45. ?>
  46. --EXPECTF--
  47. Warning: Undefined variable $x in %s on line %d
  48. Attempt to assign property "a" on null
  49. Warning: Undefined variable $x in %s on line %d
  50. Attempt to modify property "a" on null
  51. Warning: Undefined variable $x in %s on line %d
  52. Attempt to increment/decrement property "a" on null
  53. Warning: Undefined variable $x in %s on line %d
  54. Attempt to modify property "a" on null
  55. Warning: Undefined variable $x in %s on line %d
  56. Attempt to assign property "a" on null
  57. Warning: Undefined variable $x in %s on line %d
  58. Attempt to modify property "a" on null
  59. Warning: Undefined variable $x in %s on line %d
  60. Warning: Undefined variable $x in %s on line %d
  61. Warning: Undefined variable $x in %s on line %d
  62. Warning: Undefined array key 0 in %s on line %d
  63. Warning: Undefined variable $x in %s on line %d
  64. Warning: Undefined array key 0 in %s on line %d
  65. Warning: Undefined array key 0 in %s on line %d
  66. Warning: Undefined variable $x in %s on line %d
  67. Warning: Undefined array key 0 in %s on line %d
  68. Warning: Undefined variable $x in %s on line %d
  69. Warning: Undefined array key 0 in %s on line %d
  70. Warning: Undefined array key 0 in %s on line %d
  71. Warning: Undefined variable $x in %s on line %d
  72. NULL