chiark / gitweb /
686eaf0940eaca64ee4134d49c26b3ec55d086af
[termux-packages] / packages / php / zend_accelerator_module.c.patch
1 From 003346c450b58a07af9e0061bffb14c287c39be8 Mon Sep 17 00:00:00 2001
2 From: Dmitry Stogov <dmitry@zend.com>
3 Date: Thu, 1 Dec 2016 10:30:02 +0300
4 Subject: [PATCH] Simpler overflow check
5
6 ---
7  ext/opcache/zend_accelerator_module.c | 8 +++-----
8  1 file changed, 3 insertions(+), 5 deletions(-)
9
10 diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c
11 index b6c8e13..cbc3f24 100644
12 --- a/ext/opcache/zend_accelerator_module.c
13 +++ b/ext/opcache/zend_accelerator_module.c
14 @@ -107,8 +107,6 @@ static ZEND_INI_MH(OnUpdateMemoryConsumption)
15  #else
16         char *base = (char *) ts_resource(*((int *) mh_arg2));
17  #endif
18 -       zend_long megabyte, overflow;
19 -       double dummy;
20  
21         /* keep the compiler happy */
22         (void)entry; (void)mh_arg2; (void)mh_arg3; (void)stage;
23 @@ -132,10 +130,10 @@ static ZEND_INI_MH(OnUpdateMemoryConsumption)
24  
25                 ini_entry->value = zend_string_init(new_new_value, 1, 1);
26         }
27 -       megabyte = 1024 * 1024;
28 -       ZEND_SIGNED_MULTIPLY_LONG(memsize, megabyte, *p, dummy, overflow);
29 -       if (UNEXPECTED(overflow)) {
30 +       if (UNEXPECTED(memsize > ZEND_ULONG_MAX / (1024 * 1024))) {
31                 *p = ZEND_ULONG_MAX;
32 +       } else {
33 +               *p = memsize * (1024 * 1024);
34         }
35         return SUCCESS;
36  }