From b42532f1f49d9f404b100fe1a441de0c131673ee Mon Sep 17 00:00:00 2001 From: Emiel Bruijntjes Date: Sun, 25 Jan 2015 18:51:27 +0100 Subject: fixed include order, and fixed added Php::Constant to Php::Class objects --- phpcpp.h | 2 +- zend/constantimpl.h | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/phpcpp.h b/phpcpp.h index 1d7abc0..dd89a2d 100644 --- a/phpcpp.h +++ b/phpcpp.h @@ -57,9 +57,9 @@ #include #include #include +#include #include #include -#include #include #include #include diff --git a/zend/constantimpl.h b/zend/constantimpl.h index bfae410..7320a8b 100644 --- a/zend/constantimpl.h +++ b/zend/constantimpl.h @@ -116,7 +116,7 @@ public: * Add the constant to a class * @param clss The class to add it to */ - void addTo(ClassBase &clss) + void addTo(ClassBase &clss) const { // check the zval type switch (Z_TYPE(_constant.value)) { @@ -149,11 +149,18 @@ public: default: // this should not happen, the constant can only be constructed as one // of the above types, so it should be impossible to end up here. But - // for completeness, we convert the constant to a string, here - convert_to_string(&_constant.value); + // for completeness, we are going to make a copy of the zval, and convert + // that to a string + zval copy = _constant.value; + + // run the copy constructor to make sure zval is correctly copied + zval_copy_ctor(©); + + // convert the copy to a string + convert_to_string(©); // set as string constant - clss.property(_name, std::string(Z_STRVAL(_constant.value), Z_STRLEN(_constant.value)), Php::Const); + clss.property(_name, std::string(Z_STRVAL(copy), Z_STRLEN(copy)), Php::Const); break; } } -- cgit v1.2.3