File tree 5 files changed +24
-3
lines changed 5 files changed +24
-3
lines changed Original file line number Diff line number Diff line change 2
2
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
3
3
?? ??? ????, PHP 8.3.18
4
4
5
+ - BCMath:
6
+ . Fixed bug GH-17398 (bcmul memory leak). (SakiTakamachi)
5
7
6
8
13 Feb 2025, PHP 8.3.17
7
9
Original file line number Diff line number Diff line change @@ -96,9 +96,9 @@ static PHP_GINIT_FUNCTION(bcmath)
96
96
/* {{{ PHP_GSHUTDOWN_FUNCTION */
97
97
static PHP_GSHUTDOWN_FUNCTION (bcmath )
98
98
{
99
- _bc_free_num_ex (& bcmath_globals -> _zero_ , 1 );
100
- _bc_free_num_ex (& bcmath_globals -> _one_ , 1 );
101
- _bc_free_num_ex (& bcmath_globals -> _two_ , 1 );
99
+ bc_force_free_number (& bcmath_globals -> _zero_ );
100
+ bc_force_free_number (& bcmath_globals -> _one_ );
101
+ bc_force_free_number (& bcmath_globals -> _two_ );
102
102
}
103
103
/* }}} */
104
104
Original file line number Diff line number Diff line change @@ -87,6 +87,8 @@ typedef struct bc_struct {
87
87
88
88
void bc_init_numbers (void );
89
89
90
+ void bc_force_free_number (bc_num * num );
91
+
90
92
bc_num _bc_new_num_ex (size_t length , size_t scale , bool persistent );
91
93
92
94
void _bc_free_num_ex (bc_num * num , bool persistent );
Original file line number Diff line number Diff line change @@ -82,6 +82,13 @@ void bc_init_numbers(void)
82
82
BCG (_two_ )-> n_value [0 ] = 2 ;
83
83
}
84
84
85
+ void bc_force_free_number (bc_num * num )
86
+ {
87
+ pefree ((* num )-> n_ptr , 1 );
88
+ pefree (* num , 1 );
89
+ * num = NULL ;
90
+ }
91
+
85
92
86
93
/* Make a copy of a number! Just increments the reference count! */
87
94
bc_num bc_copy_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