You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
1.9 KiB

13 years ago
13 years ago
13 years ago
  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. Notice: Undefined variable: x in %s on line %d
  48. Attempt to assign property 'a' of non-object
  49. Notice: Undefined variable: x in %s on line %d
  50. Attempt to modify property 'a' of non-object
  51. Notice: Undefined variable: x in %s on line %d
  52. Attempt to increment/decrement property 'a' of non-object
  53. Notice: Undefined variable: x in %s on line %d
  54. Attempt to modify property 'a' of non-object
  55. Notice: Undefined variable: x in %s on line %d
  56. Attempt to assign property 'a' of non-object
  57. Notice: Undefined variable: x in %s on line %d
  58. Attempt to modify property 'a' of non-object
  59. Notice: Undefined variable: x in %s on line %d
  60. Notice: Undefined variable: x in %s on line %d
  61. Notice: Undefined variable: x in %s on line %d
  62. Notice: Undefined offset: 0 in %s on line %d
  63. Notice: Undefined variable: x in %s on line %d
  64. Notice: Undefined offset: 0 in %s on line %d
  65. Notice: Undefined offset: 0 in %s on line %d
  66. Notice: Undefined variable: x in %s on line %d
  67. Notice: Undefined offset: 0 in %s on line %d
  68. Notice: Undefined variable: x in %s on line %d
  69. Notice: Undefined offset: 0 in %s on line %d
  70. Notice: Undefined offset: 0 in %s on line %d
  71. Notice: Undefined variable: x in %s on line %d
  72. NULL