mirror of
https://github.com/php/php-src.git
synced 2025-08-17 14:38:49 +02:00
Simpler overflow check
This commit is contained in:
parent
d5a2af6d1c
commit
003346c450
1 changed files with 3 additions and 5 deletions
|
@ -107,8 +107,6 @@ static ZEND_INI_MH(OnUpdateMemoryConsumption)
|
||||||
#else
|
#else
|
||||||
char *base = (char *) ts_resource(*((int *) mh_arg2));
|
char *base = (char *) ts_resource(*((int *) mh_arg2));
|
||||||
#endif
|
#endif
|
||||||
zend_long megabyte, overflow;
|
|
||||||
double dummy;
|
|
||||||
|
|
||||||
/* keep the compiler happy */
|
/* keep the compiler happy */
|
||||||
(void)entry; (void)mh_arg2; (void)mh_arg3; (void)stage;
|
(void)entry; (void)mh_arg2; (void)mh_arg3; (void)stage;
|
||||||
|
@ -132,10 +130,10 @@ static ZEND_INI_MH(OnUpdateMemoryConsumption)
|
||||||
|
|
||||||
ini_entry->value = zend_string_init(new_new_value, 1, 1);
|
ini_entry->value = zend_string_init(new_new_value, 1, 1);
|
||||||
}
|
}
|
||||||
megabyte = 1024 * 1024;
|
if (UNEXPECTED(memsize > ZEND_ULONG_MAX / (1024 * 1024))) {
|
||||||
ZEND_SIGNED_MULTIPLY_LONG(memsize, megabyte, *p, dummy, overflow);
|
|
||||||
if (UNEXPECTED(overflow)) {
|
|
||||||
*p = ZEND_ULONG_MAX;
|
*p = ZEND_ULONG_MAX;
|
||||||
|
} else {
|
||||||
|
*p = memsize * (1024 * 1024);
|
||||||
}
|
}
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue