@@ -804,35 +804,29 @@ static bool zlib_create_dictionary_string(HashTable *options, char **dict, size_
804
804
if (zend_hash_num_elements (dictionary ) > 0 ) {
805
805
char * dictptr ;
806
806
zval * cur ;
807
- zend_string * * strings = emalloc ( sizeof (zend_string * ) * zend_hash_num_elements ( dictionary ) );
807
+ zend_string * * strings = safe_emalloc ( zend_hash_num_elements ( dictionary ), sizeof (zend_string * ), 0 );
808
808
zend_string * * end , * * ptr = strings - 1 ;
809
809
810
810
ZEND_HASH_FOREACH_VAL (dictionary , cur ) {
811
- size_t i ;
812
-
813
811
* ++ ptr = zval_get_string (cur );
814
- if (!* ptr || ZSTR_LEN (* ptr ) == 0 || EG (exception )) {
815
- if (* ptr ) {
816
- efree (* ptr );
817
- }
818
- while (-- ptr >= strings ) {
819
- efree (ptr );
820
- }
812
+ ZEND_ASSERT (* ptr );
813
+ if (ZSTR_LEN (* ptr ) == 0 || EG (exception )) {
814
+ do {
815
+ zend_string_release (* ptr );
816
+ } while (-- ptr >= strings );
821
817
efree (strings );
822
818
if (!EG (exception )) {
823
819
zend_argument_value_error (2 , "must not contain empty strings" );
824
820
}
825
821
return 0 ;
826
822
}
827
- for (i = 0 ; i < ZSTR_LEN (* ptr ); i ++ ) {
828
- if (ZSTR_VAL (* ptr )[i ] == 0 ) {
829
- do {
830
- efree (ptr );
831
- } while (-- ptr >= strings );
832
- efree (strings );
833
- zend_argument_value_error (2 , "must not contain strings with null bytes" );
834
- return 0 ;
835
- }
823
+ if (zend_str_has_nul_byte (* ptr )) {
824
+ do {
825
+ zend_string_release (* ptr );
826
+ } while (-- ptr >= strings );
827
+ efree (strings );
828
+ zend_argument_value_error (2 , "must not contain strings with null bytes" );
829
+ return 0 ;
836
830
}
837
831
838
832
* dictlen += ZSTR_LEN (* ptr ) + 1 ;
0 commit comments