Re: Programming question
| From: | Zeev Suraski | Date: | Thu, 02 Aug 2001 17:34:02 +0000 |
| Subject: | Re: Programming question | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-61855@lists.php.net to get a copy of this message | ||
Actually, any code in PHP can assume this. Any zval coming from the engine is NULL terminated, so zval.str.val[zval.str.len] is always NULL. Obviously, if you create the string, you have to NULL terminate it before you can assume that :)
If a string is not NULL terminated, it is a bug.
At 09:18 02/08/2001, Rasmus Lerdorf wrote:
can it be assumed that zval.str.val[zval.str.len] = '\0'? i.e., the byte after the string in a zval is the null-byte? That is assumed in various places in ext/standard/string.c, and AFAIK that may not always be true. No code in PHP should assume this. PHP should always check the length. However, many external libraries that take string arguments are not going to be able to check our length property and we therefore should strive to null-terminate all strings. I noticed Thies has been going through recently and cleaning this up a bit. -Rasmus -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net For additional commands, e-mail: php-dev-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net-- Zeev Suraski <zeev@zend.com> CTO & co-founder, Zend Technologies Ltd. http://www.zend.com/