summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2015-01-19 22:23:48 +0100
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2015-01-19 22:23:48 +0100
commitf7ab1cd465cba96635b79281efef4790edc38a1a (patch)
tree382abc308935d1b4615ddcab8ea33e24cb2989f6
parent237c13779a0a30bf8a1fbfa94a8cc96f8b27ef59 (diff)
fixed weird name_len (for constants it apparently includes the null byte)
-rw-r--r--zend/constantimpl.h14
1 files changed, 6 insertions, 8 deletions
diff --git a/zend/constantimpl.h b/zend/constantimpl.h
index 096cb5c..bf2ac25 100644
--- a/zend/constantimpl.h
+++ b/zend/constantimpl.h
@@ -126,24 +126,22 @@ public:
// size of the name
auto namelen = ::strlen(_name);
- // include prefix in the full name
- _constant.name_len = prefix.size() + 1 + namelen;
+ // include prefix in the full name (name_len should include '\0')
+ _constant.name_len = prefix.size() + 1 + namelen + 1;
_constant.name = (char *)emalloc(_constant.name_len);
// copy the entire namespace name, separator and constant name
::strncpy(_constant.name, prefix.c_str(), prefix.size());
::strncpy(_constant.name + prefix.size(), "\\", 1);
- ::strncpy(_constant.name + prefix.size() + 1, _name, namelen);
+ ::strncpy(_constant.name + prefix.size() + 1, _name, namelen + 1);
}
else
{
- // no namespace, we simply copy the name
- _constant.name_len = ::strlen(_name);
- _constant.name = zend_strndup(_name, _constant.name_len);
+ // no namespace, we simply copy the name (name_len should include '\0')
+ _constant.name_len = ::strlen(_name) + 1;
+ _constant.name = zend_strndup(_name, _constant.name_len - 1);
}
- std::cout << "register constant " << std::string(_constant.name, _constant.name_len) << std::endl;
-
// set all the other constant properties
_constant.flags = CONST_CS | CONST_PERSISTENT;
_constant.module_number = module_number;