@@ -493,7 +493,7 @@ PHP_FUNCTION(bzdecompress)
493
493
size_t source_len ;
494
494
int error ;
495
495
bool small = 0 ;
496
- unsigned long long size = 0 ;
496
+ uint64_t size = 0 ;
497
497
bz_stream bzs ;
498
498
499
499
if (FAILURE == zend_parse_parameters (ZEND_NUM_ARGS (), "s|b" , & source , & source_len , & small )) {
@@ -520,26 +520,22 @@ PHP_FUNCTION(bzdecompress)
520
520
/* compression is better then 2:1, need to allocate more memory */
521
521
bzs .avail_out = source_len ;
522
522
size = (bzs .total_out_hi32 * (unsigned int ) -1 ) + bzs .total_out_lo32 ;
523
- #if SIZEOF_LONG_LONG > SIZEOF_SIZE_T
524
- if (size > SIZE_MAX ) {
523
+ if (UNEXPECTED (size > SIZE_MAX )) {
525
524
/* no reason to continue if we're going to drop it anyway */
526
525
break ;
527
526
}
528
- #endif
527
+
529
528
dest = zend_string_safe_realloc (dest , 1 , bzs .avail_out + 1 , (size_t ) size , 0 );
530
529
bzs .next_out = ZSTR_VAL (dest ) + size ;
531
530
}
532
531
533
532
if (error == BZ_STREAM_END || error == BZ_OK ) {
534
533
size = (bzs .total_out_hi32 * (unsigned int ) -1 ) + bzs .total_out_lo32 ;
535
- #if SIZEOF_LONG_LONG > SIZEOF_SIZE_T
536
534
if (UNEXPECTED (size > SIZE_MAX )) {
537
535
php_error_docref (NULL , E_WARNING , "Decompressed size too big, max is %zu" , SIZE_MAX );
538
536
zend_string_efree (dest );
539
537
RETVAL_LONG (BZ_MEM_ERROR );
540
- } else
541
- #endif
542
- {
538
+ } else {
543
539
dest = zend_string_safe_realloc (dest , 1 , (size_t )size , 1 , 0 );
544
540
ZSTR_LEN (dest ) = (size_t )size ;
545
541
ZSTR_VAL (dest )[(size_t )size ] = '\0' ;
0 commit comments