Skip to content

Commit

Permalink
Value objects allocated with a const char * that is set to null, will…
Browse files Browse the repository at this point in the history
… not create NULL php values
  • Loading branch information
EmielBruijntjes committed Aug 26, 2014
1 parent 0e24f71 commit a286c34
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 0 additions & 2 deletions include/value.h
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,6 @@ class Value : private HashParent
template <typename T>
std::vector<T> vectorValue() const
{


// only works for arrays, other types return an empty vector
if (!isArray()) return std::vector<T>();

Expand Down
16 changes: 13 additions & 3 deletions zend/value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,19 @@ Value::Value(const std::string &value)
*/
Value::Value(const char *value, int size)
{
// create a string zval
MAKE_STD_ZVAL(_val);
ZVAL_STRINGL(_val, value, size < 0 ? ::strlen(value) : size, 1);
// is there a value?
if (value)
{
// create a string zval
MAKE_STD_ZVAL(_val);
ZVAL_STRINGL(_val, value, size < 0 ? ::strlen(value) : size, 1);
}
else
{
// create a null zval
MAKE_STD_ZVAL(_val);
ZVAL_NULL(_val);
}
}

/**
Expand Down

0 comments on commit a286c34

Please sign in to comment.