Skip to content

Commit

Permalink
Simpler overflow check
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Dec 1, 2016
1 parent d5a2af6 commit 003346c
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions ext/opcache/zend_accelerator_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ static ZEND_INI_MH(OnUpdateMemoryConsumption)
#else
char *base = (char *) ts_resource(*((int *) mh_arg2));
#endif
zend_long megabyte, overflow;
double dummy;

/* keep the compiler happy */
(void)entry; (void)mh_arg2; (void)mh_arg3; (void)stage;
Expand All @@ -132,10 +130,10 @@ static ZEND_INI_MH(OnUpdateMemoryConsumption)

ini_entry->value = zend_string_init(new_new_value, 1, 1);
}
megabyte = 1024 * 1024;
ZEND_SIGNED_MULTIPLY_LONG(memsize, megabyte, *p, dummy, overflow);
if (UNEXPECTED(overflow)) {
if (UNEXPECTED(memsize > ZEND_ULONG_MAX / (1024 * 1024))) {
*p = ZEND_ULONG_MAX;
} else {
*p = memsize * (1024 * 1024);
}
return SUCCESS;
}
Expand Down

0 comments on commit 003346c

Please sign in to comment.