summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-08-26 12:49:40 +0200
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-08-26 12:49:40 +0200
commita286c34777e48d59410e7511f52f4a6f08000ba3 (patch)
tree0d6b20409d80a4073b8448e1ecc526e8165de034
parent0e24f714fa8ddc4e45b858a1eec25ef1d84e7654 (diff)
Value objects allocated with a const char * that is set to null, will not create NULL php values
-rw-r--r--include/value.h2
-rw-r--r--zend/value.cpp16
2 files changed, 13 insertions, 5 deletions
diff --git a/include/value.h b/include/value.h
index 63e8e6f..c6b1af9 100644
--- a/include/value.h
+++ b/include/value.h
@@ -441,8 +441,6 @@ public:
template <typename T>
std::vector<T> vectorValue() const
{
-
-
// only works for arrays, other types return an empty vector
if (!isArray()) return std::vector<T>();
diff --git a/zend/value.cpp b/zend/value.cpp
index 9040234..d3ad06f 100644
--- a/zend/value.cpp
+++ b/zend/value.cpp
@@ -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);
+ }
}
/**