@@ -816,12 +816,14 @@ PHP_FUNCTION(wordwrap)
816816/* }}} */
817817
818818/* {{{ php_explode */
819- PHPAPI void php_explode (const zend_string * delim , zend_string * str , zval * return_value , zend_long limit )
819+ PHPAPI void php_explode (const zend_string * delim , const zend_string * str , zval * return_value , zend_long limit )
820820{
821821 const char * p1 = ZSTR_VAL (str );
822822 const char * endp = ZSTR_VAL (str ) + ZSTR_LEN (str );
823823 const char * p2 = php_memnstr (ZSTR_VAL (str ), ZSTR_VAL (delim ), ZSTR_LEN (delim ), endp );
824824 zval tmp ;
825+ zend_string * tmp2 ;
826+ uint32_t flags = ZSTR_GET_COPYABLE_CONCAT_PROPERTIES_BOTH (delim , str );
825827
826828 if (p2 == NULL ) {
827829 ZVAL_STR_COPY (& tmp , str );
@@ -831,15 +833,19 @@ PHPAPI void php_explode(const zend_string *delim, zend_string *str, zval *return
831833 ZEND_HASH_FILL_PACKED (Z_ARRVAL_P (return_value )) {
832834 do {
833835 ZEND_HASH_FILL_GROW ();
834- ZEND_HASH_FILL_SET_STR (zend_string_init_fast (p1 , p2 - p1 ));
836+ tmp2 = zend_string_init_fast (p1 , p2 - p1 );
837+ GC_ADD_FLAGS (tmp2 , flags );
838+ ZEND_HASH_FILL_SET_STR (tmp2 );
835839 ZEND_HASH_FILL_NEXT ();
836840 p1 = p2 + ZSTR_LEN (delim );
837841 p2 = php_memnstr (p1 , ZSTR_VAL (delim ), ZSTR_LEN (delim ), endp );
838842 } while (p2 != NULL && -- limit > 1 );
839843
840844 if (p1 <= endp ) {
841845 ZEND_HASH_FILL_GROW ();
842- ZEND_HASH_FILL_SET_STR (zend_string_init_fast (p1 , endp - p1 ));
846+ tmp2 = zend_string_init_fast (p1 , endp - p1 );
847+ GC_ADD_FLAGS (tmp2 , flags );
848+ ZEND_HASH_FILL_SET_STR (tmp2 );
843849 ZEND_HASH_FILL_NEXT ();
844850 }
845851 } ZEND_HASH_FILL_END ();
@@ -848,13 +854,14 @@ PHPAPI void php_explode(const zend_string *delim, zend_string *str, zval *return
848854/* }}} */
849855
850856/* {{{ php_explode_negative_limit */
851- PHPAPI void php_explode_negative_limit (const zend_string * delim , zend_string * str , zval * return_value , zend_long limit )
857+ PHPAPI void php_explode_negative_limit (const zend_string * delim , const zend_string * str , zval * return_value , zend_long limit )
852858{
853859#define EXPLODE_ALLOC_STEP 64
854860 const char * p1 = ZSTR_VAL (str );
855861 const char * endp = ZSTR_VAL (str ) + ZSTR_LEN (str );
856862 const char * p2 = php_memnstr (ZSTR_VAL (str ), ZSTR_VAL (delim ), ZSTR_LEN (delim ), endp );
857863 zval tmp ;
864+ uint32_t flags = ZSTR_GET_COPYABLE_CONCAT_PROPERTIES_BOTH (delim , str );
858865
859866 if (p2 == NULL ) {
860867 /*
@@ -880,6 +887,7 @@ PHPAPI void php_explode_negative_limit(const zend_string *delim, zend_string *st
880887 /* limit is at least -1 therefore no need of bounds checking : i will be always less than found */
881888 for (i = 0 ; i < to_return ; i ++ ) { /* this checks also for to_return > 0 */
882889 ZVAL_STRINGL (& tmp , positions [i ], (positions [i + 1 ] - ZSTR_LEN (delim )) - positions [i ]);
890+ GC_ADD_FLAGS (Z_STR (tmp ), flags );
883891 zend_hash_next_index_insert_new (Z_ARRVAL_P (return_value ), & tmp );
884892 }
885893 efree ((void * )positions );
0 commit comments