On Wed, August 27, 2014 01:32, Nikita Popov wrote: > On Mon, Aug 18, 2014 at 3:39 PM, Anatol Belski <a...@php.net> wrote: > > >> Commit: 97e9d058f09c12161863e5c3832552eb5da3f3c6 >> Author: Anatol Belski <a...@php.net> Mon, 18 Aug 2014 15:39:38 >> +0200 >> Parents: 22dbb38d5e234f5987e226298ba9b86d9f9ea52a >> Branches: master >> >> >> Link: >> http://git.php.net/?p=php-src.git;a=commitdiff;h=97e9d058f09c12161863e5c >> 3832552eb5da3f3c6 >> >> >> Log: >> fixes to string functions >> >> Changed paths: >> M ext/standard/php_string.h >> M ext/standard/string.c >> >> > > The changes here related to using STR_INIT for a zpp default value won't > work correctly (also including followup changes). The way it is currently > implemented you will still get leaks (e.g. if the str_pad default *is* > used) or segfaults (if zpp fails after assigning the pad value). > > I would suggest reverting the STR_INIT related changes altogether, or if > you want to use this approach, then the zend_string for the default value > should be allocated on startup and destroyed on shutdown. > yeah, that's why I made the follow ups like this
http://git.php.net/?p=php-src.git;a=commitdiff;h=6bea54b7b9d5fff11bf40ab0464800baa9fbada3 http://git.php.net/?p=php-src.git;a=commitdiff;h=98bb620bfe132fbc3ee6c4e630e859ab6dc8ba78 Those are failsafe, however i'm not sure it'll work always with interned strings and anyway it's overkill for the default value. Of course, that can be reverted back to 's', in most cases that will suffice (like for pad_str in str_pad()). Probably can be done if one can't initialize zend_string to a default value for ZPP. But actually, to not to allocate, can we initialize zend_string with an interned string? As often something like "", "\n" (so a simple char) was used for that. Thanks Anatol -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php