@@ -805,35 +805,29 @@ static bool zlib_create_dictionary_string(HashTable *options, char **dict, size_
805805 if (zend_hash_num_elements (dictionary ) > 0 ) {
806806 char * dictptr ;
807807 zval * cur ;
808- zend_string * * strings = emalloc ( sizeof (zend_string * ) * zend_hash_num_elements ( dictionary ) );
808+ zend_string * * strings = safe_emalloc ( zend_hash_num_elements ( dictionary ), sizeof (zend_string * ), 0 );
809809 zend_string * * end , * * ptr = strings - 1 ;
810810
811811 ZEND_HASH_FOREACH_VAL (dictionary , cur ) {
812- size_t i ;
813-
814812 * ++ ptr = zval_get_string (cur );
815- if (!* ptr || ZSTR_LEN (* ptr ) == 0 || EG (exception )) {
816- if (* ptr ) {
817- efree (* ptr );
818- }
819- while (-- ptr >= strings ) {
820- efree (ptr );
821- }
813+ ZEND_ASSERT (* ptr );
814+ if (ZSTR_LEN (* ptr ) == 0 || EG (exception )) {
815+ do {
816+ zend_string_release (* ptr );
817+ } while (-- ptr >= strings );
822818 efree (strings );
823819 if (!EG (exception )) {
824820 zend_argument_value_error (2 , "must not contain empty strings" );
825821 }
826822 return 0 ;
827823 }
828- for (i = 0 ; i < ZSTR_LEN (* ptr ); i ++ ) {
829- if (ZSTR_VAL (* ptr )[i ] == 0 ) {
830- do {
831- efree (ptr );
832- } while (-- ptr >= strings );
833- efree (strings );
834- zend_argument_value_error (2 , "must not contain strings with null bytes" );
835- return 0 ;
836- }
824+ if (zend_str_has_nul_byte (* ptr )) {
825+ do {
826+ zend_string_release (* ptr );
827+ } while (-- ptr >= strings );
828+ efree (strings );
829+ zend_argument_value_error (2 , "must not contain strings with null bytes" );
830+ return 0 ;
837831 }
838832
839833 * dictlen += ZSTR_LEN (* ptr ) + 1 ;
0 commit comments