File tree Expand file tree Collapse file tree 4 files changed +22
-3
lines changed Expand file tree Collapse file tree 4 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -109,9 +109,9 @@ static PHP_GINIT_FUNCTION(bcmath)
109
109
/* {{{ PHP_GSHUTDOWN_FUNCTION */
110
110
static PHP_GSHUTDOWN_FUNCTION (bcmath )
111
111
{
112
- _bc_free_num_ex (& bcmath_globals -> _zero_ , 1 );
113
- _bc_free_num_ex (& bcmath_globals -> _one_ , 1 );
114
- _bc_free_num_ex (& bcmath_globals -> _two_ , 1 );
112
+ bc_force_free_number (& bcmath_globals -> _zero_ );
113
+ bc_force_free_number (& bcmath_globals -> _one_ );
114
+ bc_force_free_number (& bcmath_globals -> _two_ );
115
115
bcmath_globals -> arena = NULL ;
116
116
bcmath_globals -> arena_offset = 0 ;
117
117
}
Original file line number Diff line number Diff line change @@ -78,6 +78,8 @@ typedef struct bc_struct {
78
78
79
79
void bc_init_numbers (void );
80
80
81
+ void bc_force_free_number (bc_num * num );
82
+
81
83
bc_num _bc_new_num_ex (size_t length , size_t scale , bool persistent );
82
84
83
85
bc_num _bc_new_num_nonzeroed_ex (size_t length , size_t scale , bool persistent );
Original file line number Diff line number Diff line change @@ -97,6 +97,13 @@ void bc_init_numbers(void)
97
97
BCG (_two_ )-> n_value [0 ] = 2 ;
98
98
}
99
99
100
+ void bc_force_free_number (bc_num * num )
101
+ {
102
+ pefree ((* num )-> n_ptr , 1 );
103
+ pefree (* num , 1 );
104
+ * num = NULL ;
105
+ }
106
+
100
107
101
108
/* Initialize a number NUM by making it a copy of zero. */
102
109
void bc_init_num (bc_num * num )
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ GH-17398 (bcmul memory leak)
3
+ --EXTENSIONS--
4
+ bcmath
5
+ --FILE--
6
+ <?php
7
+ bcmul ('0 ' , '0 ' , 2147483647 );
8
+ ?>
9
+ --EXPECTF--
10
+ Fatal error: Allowed memory size of %d bytes exhausted%s(tried to allocate %d bytes) in %s on line %d
You can’t perform that action at this time.
0 commit comments