Skip to content

Commit 2fde338

Browse files
committed
Use uint64_t and removed preprocessor checks
1 parent 37e3c9e commit 2fde338

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

ext/bz2/bz2.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ PHP_FUNCTION(bzdecompress)
493493
size_t source_len;
494494
int error;
495495
bool small = 0;
496-
unsigned long long size = 0;
496+
uint64_t size = 0;
497497
bz_stream bzs;
498498

499499
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &source, &source_len, &small)) {
@@ -520,26 +520,22 @@ PHP_FUNCTION(bzdecompress)
520520
/* compression is better then 2:1, need to allocate more memory */
521521
bzs.avail_out = source_len;
522522
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)) {
525524
/* no reason to continue if we're going to drop it anyway */
526525
break;
527526
}
528-
#endif
527+
529528
dest = zend_string_safe_realloc(dest, 1, bzs.avail_out+1, (size_t) size, 0);
530529
bzs.next_out = ZSTR_VAL(dest) + size;
531530
}
532531

533532
if (error == BZ_STREAM_END || error == BZ_OK) {
534533
size = (bzs.total_out_hi32 * (unsigned int) -1) + bzs.total_out_lo32;
535-
#if SIZEOF_LONG_LONG > SIZEOF_SIZE_T
536534
if (UNEXPECTED(size > SIZE_MAX)) {
537535
php_error_docref(NULL, E_WARNING, "Decompressed size too big, max is %zu", SIZE_MAX);
538536
zend_string_efree(dest);
539537
RETVAL_LONG(BZ_MEM_ERROR);
540-
} else
541-
#endif
542-
{
538+
} else {
543539
dest = zend_string_safe_realloc(dest, 1, (size_t)size, 1, 0);
544540
ZSTR_LEN(dest) = (size_t)size;
545541
ZSTR_VAL(dest)[(size_t)size] = '\0';

0 commit comments

Comments
 (0)