@@ -804,35 +804,29 @@ static bool zlib_create_dictionary_string(HashTable *options, char **dict, size_
804804 if (zend_hash_num_elements (dictionary ) > 0 ) {
805805 char * dictptr ;
806806 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 );
808808 zend_string * * end , * * ptr = strings - 1 ;
809809
810810 ZEND_HASH_FOREACH_VAL (dictionary , cur ) {
811- size_t i ;
812-
813811 * ++ 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 );
821817 efree (strings );
822818 if (!EG (exception )) {
823819 zend_argument_value_error (2 , "must not contain empty strings" );
824820 }
825821 return 0 ;
826822 }
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 ;
836830 }
837831
838832 * dictlen += ZSTR_LEN (* ptr ) + 1 ;
0 commit comments