Skip to content

Commit d4b3f89

Browse files
committed
Overflow check
1 parent 5e001c3 commit d4b3f89

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

ext/opcache/zend_accelerator_module.c

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

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

131133
ini_entry->value = zend_string_init(new_new_value, 1, 1);
132134
}
133-
*p = memsize * (1024 * 1024);
135+
ZEND_SIGNED_MULTIPLY_LONG(memsize, 1024 * 1024, *p, dummy, overflow);
136+
if (UNEXPECTED(overflow)) {
137+
*p = ZEND_ULONG_MAX;
138+
}
134139
return SUCCESS;
135140
}
136141

0 commit comments

Comments
 (0)