Edit report at https://bugs.php.net/bug.php?id=55382&edit=1

 ID:                 55382
 Comment by:         ava3ar at gmail dot com
 Reported by:        ava3ar at gmail dot com
 Summary:            Crash on GLOBALS inside traits
 Status:             Open
 Type:               Bug
 Package:            Unknown/Other Function
 Operating System:   Gentoo
 PHP Version:        5.4SVN-2011-08-08 (SVN)
 Block user comment: N
 Private report:     N

 New Comment:

If you change the test trait to

<?php
trait test {
 function tester($cCookie) { 
  if ($cCookie) {
   if (isset($_COOKIE[$cCookie])) {
    return $_COOKIE[$cCookie];
   }
  }
  return false;
 }
}

//
you get a zend_mm_corrupt


Previous Comments:
------------------------------------------------------------------------
[2011-08-08 15:17:10] ava3ar at gmail dot com

Description:
------------
if you use GLOBAL variables inside traits, e.g. $_COOKIE, it segfaults

Test script:
---------------
<?php
trait test {
 function tester($cCookie = false) { 
  if ($cCookie) {
   if (isset($_COOKIE[$cCookie])) {
    return $_COOKIE[$cCookie];
   }
  }
  return false;
 }
}

<?php
class asda {
 use test;
 function beep() {
  $this->tester("test");
 }
}

$a = new asda();
echo $a->beep();

Expected result:
----------------
false, or contents

Actual result:
--------------
Segfault


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=55382&edit=1

Reply via email to