#36814 [NEW]: ArrayObject is leaking. Seems that OffsetGet should use OffsetExists
| From: | raphaelpereira at gmail dot com | Date: | Tue, 21 Mar 2006 14:50:42 +0000 |
| Subject: | #36814 [NEW]: ArrayObject is leaking. Seems that OffsetGet should use OffsetExists | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-94713@lists.php.net to get a copy of this message | ||
From: raphaelpereira at gmail dot com
Operating system: Ubuntu Hoary
PHP version: 5.1.2
PHP Bug Type: SPL related
Bug description: ArrayObject is leaking. Seems that OffsetGet should use OffsetExists
Description:
------------
My code is very complex and I could not reproduce the bug in another code,
but the issue is that it seems that ArrayObject::offsetGet doesn't check if
the key exists to return it and in some very specific case this returns
invalid results.
The problem is in my query_constraints class. On its constructor I
declare:
class query_constraints
{
protected $_dados;
public function __construct ($params=null)
{
$this->_dados = new ArrayObject();
$this->_dados['in'] = new ArrayObject();
$this->_dados['eq'] = new ArrayObject();
...
Later on I have:
public function equal($campo, $valor)
{
if (!$this->_dados['eq'][$campo] &&
!$this->_dados['in'][$campo])
{
...
Both tests returns false on the first call to this method just after
object construction.
To workaroud the problem I substituted all references to ArrayObject in
this class with the following class:
class ArrayObject1 extends ArrayObject
{
public function offsetget($key)
{
if ($this->offsetexists($key))
return parent::offsetget($key);
return null;
}
}
This solved my problem.
--
Edit bug report at http://bugs.php.net/?id=36814&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=36814&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=36814&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=36814&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=36814&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=36814&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=36814&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=36814&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=36814&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=36814&r=support
Expected behavior: http://bugs.php.net/fix.php?id=36814&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=36814&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=36814&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=36814&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=36814&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=36814&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=36814&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=36814&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=36814&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=36814&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=36814&r=mysqlcfg