@@ -816,12 +816,14 @@ PHP_FUNCTION(wordwrap)
816
816
/* }}} */
817
817
818
818
/* {{{ 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 )
820
820
{
821
821
const char * p1 = ZSTR_VAL (str );
822
822
const char * endp = ZSTR_VAL (str ) + ZSTR_LEN (str );
823
823
const char * p2 = php_memnstr (ZSTR_VAL (str ), ZSTR_VAL (delim ), ZSTR_LEN (delim ), endp );
824
824
zval tmp ;
825
+ zend_string * tmp2 ;
826
+ uint32_t flags = ZSTR_GET_COPYABLE_CONCAT_PROPERTIES_BOTH (delim , str );
825
827
826
828
if (p2 == NULL ) {
827
829
ZVAL_STR_COPY (& tmp , str );
@@ -831,15 +833,19 @@ PHPAPI void php_explode(const zend_string *delim, zend_string *str, zval *return
831
833
ZEND_HASH_FILL_PACKED (Z_ARRVAL_P (return_value )) {
832
834
do {
833
835
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 );
835
839
ZEND_HASH_FILL_NEXT ();
836
840
p1 = p2 + ZSTR_LEN (delim );
837
841
p2 = php_memnstr (p1 , ZSTR_VAL (delim ), ZSTR_LEN (delim ), endp );
838
842
} while (p2 != NULL && -- limit > 1 );
839
843
840
844
if (p1 <= endp ) {
841
845
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 );
843
849
ZEND_HASH_FILL_NEXT ();
844
850
}
845
851
} ZEND_HASH_FILL_END ();
@@ -848,13 +854,14 @@ PHPAPI void php_explode(const zend_string *delim, zend_string *str, zval *return
848
854
/* }}} */
849
855
850
856
/* {{{ 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 )
852
858
{
853
859
#define EXPLODE_ALLOC_STEP 64
854
860
const char * p1 = ZSTR_VAL (str );
855
861
const char * endp = ZSTR_VAL (str ) + ZSTR_LEN (str );
856
862
const char * p2 = php_memnstr (ZSTR_VAL (str ), ZSTR_VAL (delim ), ZSTR_LEN (delim ), endp );
857
863
zval tmp ;
864
+ uint32_t flags = ZSTR_GET_COPYABLE_CONCAT_PROPERTIES_BOTH (delim , str );
858
865
859
866
if (p2 == NULL ) {
860
867
/*
@@ -880,6 +887,7 @@ PHPAPI void php_explode_negative_limit(const zend_string *delim, zend_string *st
880
887
/* limit is at least -1 therefore no need of bounds checking : i will be always less than found */
881
888
for (i = 0 ; i < to_return ; i ++ ) { /* this checks also for to_return > 0 */
882
889
ZVAL_STRINGL (& tmp , positions [i ], (positions [i + 1 ] - ZSTR_LEN (delim )) - positions [i ]);
890
+ GC_ADD_FLAGS (Z_STR (tmp ), flags );
883
891
zend_hash_next_index_insert_new (Z_ARRVAL_P (return_value ), & tmp );
884
892
}
885
893
efree ((void * )positions );
0 commit comments