Skip to content

Commit

Permalink
Alway dereference our value, if it is not a reference we get the orig…
Browse files Browse the repository at this point in the history
…inal back again
  • Loading branch information
raidiant committed Aug 30, 2018
1 parent 09376e3 commit c6454f0
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions zend/value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1140,18 +1140,12 @@ bool Value::isCallable() const
*/
zend_class_entry *Value::classEntry(bool allowString) const
{
// are we a reference
if (isReference())
{
// we go through the reference to retrieve the object
return Z_OBJCE_P(Z_REFVAL_P(_val));
}

// is this an object
else if (isObject())
if (isObject())
{
// class entry can be easily found
return Z_OBJCE_P(_val);
// class entry can be easily found, we try to dereference here if our
// value is a reference to an object
return Z_OBJCE_P(_val.dereference());
}

else
Expand Down Expand Up @@ -1795,11 +1789,9 @@ HashMember<std::string> Value::operator[](const char *key)
*/
Base *Value::implementation() const
{
// are we a reference
if (isReference()) return ObjectImpl::find(Z_REFVAL_P(_val))->object();

// must be an object
if (isObject()) return ObjectImpl::find(_val)->object();
// must be an object, we try to dereference because we might be a reference
// to an object
if (isObject()) return ObjectImpl::find(_val.dereference())->object();

// retrieve the mixed object that contains the base
return nullptr;
Expand Down

0 comments on commit c6454f0

Please sign in to comment.