@@ -504,11 +504,7 @@ PHP_FUNCTION(bzdecompress)
504504 size_t source_len ;
505505 int error ;
506506 bool small = 0 ;
507- #ifdef PHP_WIN32
508- unsigned __int64 size = 0 ;
509- #else
510- unsigned long long size = 0 ;
511- #endif
507+ uint64_t size = 0 ;
512508 bz_stream bzs ;
513509
514510 if (FAILURE == zend_parse_parameters (ZEND_NUM_ARGS (), "s|b" , & source , & source_len , & small )) {
@@ -535,26 +531,22 @@ PHP_FUNCTION(bzdecompress)
535531 /* compression is better then 2:1, need to allocate more memory */
536532 bzs .avail_out = source_len ;
537533 size = (bzs .total_out_hi32 * (unsigned int ) -1 ) + bzs .total_out_lo32 ;
538- #ifndef ZEND_ENABLE_ZVAL_LONG64
539- if (size > SIZE_MAX ) {
534+ if (UNEXPECTED (size > SIZE_MAX )) {
540535 /* no reason to continue if we're going to drop it anyway */
541536 break ;
542537 }
543- #endif
538+
544539 dest = zend_string_safe_realloc (dest , 1 , bzs .avail_out + 1 , (size_t ) size , 0 );
545540 bzs .next_out = ZSTR_VAL (dest ) + size ;
546541 }
547542
548543 if (error == BZ_STREAM_END || error == BZ_OK ) {
549544 size = (bzs .total_out_hi32 * (unsigned int ) -1 ) + bzs .total_out_lo32 ;
550- #ifndef ZEND_ENABLE_ZVAL_LONG64
551545 if (UNEXPECTED (size > SIZE_MAX )) {
552- php_error_docref (NULL , E_WARNING , "Decompressed size too big, max is %zd " , SIZE_MAX );
546+ php_error_docref (NULL , E_WARNING , "Decompressed size too big, max is %zu " , SIZE_MAX );
553547 zend_string_efree (dest );
554548 RETVAL_LONG (BZ_MEM_ERROR );
555- } else
556- #endif
557- {
549+ } else {
558550 dest = zend_string_safe_realloc (dest , 1 , (size_t )size , 1 , 0 );
559551 ZSTR_LEN (dest ) = (size_t )size ;
560552 ZSTR_VAL (dest )[(size_t )size ] = '\0' ;
0 commit comments