Skip to content

Commit 003346c

Browse files
committed
Simpler overflow check
1 parent d5a2af6 commit 003346c

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

ext/opcache/zend_accelerator_module.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ static ZEND_INI_MH(OnUpdateMemoryConsumption)
107107
#else
108108
char *base = (char *) ts_resource(*((int *) mh_arg2));
109109
#endif
110-
zend_long megabyte, overflow;
111-
double dummy;
112110

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

133131
ini_entry->value = zend_string_init(new_new_value, 1, 1);
134132
}
135-
megabyte = 1024 * 1024;
136-
ZEND_SIGNED_MULTIPLY_LONG(memsize, megabyte, *p, dummy, overflow);
137-
if (UNEXPECTED(overflow)) {
133+
if (UNEXPECTED(memsize > ZEND_ULONG_MAX / (1024 * 1024))) {
138134
*p = ZEND_ULONG_MAX;
135+
} else {
136+
*p = memsize * (1024 * 1024);
139137
}
140138
return SUCCESS;
141139
}

0 commit comments

Comments
 (0)