File tree Expand file tree Collapse file tree 5 files changed +24
-3
lines changed Expand file tree Collapse file tree 5 files changed +24
-3
lines changed Original file line number Diff line number Diff line change 22|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33?? ??? ????, PHP 8.3.18
44
5+ - BCMath:
6+ . Fixed bug GH-17398 (bcmul memory leak). (SakiTakamachi)
57
6813 Feb 2025, PHP 8.3.17
79
Original file line number Diff line number Diff line change @@ -96,9 +96,9 @@ static PHP_GINIT_FUNCTION(bcmath)
9696/* {{{ PHP_GSHUTDOWN_FUNCTION */
9797static PHP_GSHUTDOWN_FUNCTION (bcmath )
9898{
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_ );
102102}
103103/* }}} */
104104
Original file line number Diff line number Diff line change @@ -87,6 +87,8 @@ typedef struct bc_struct {
8787
8888void bc_init_numbers (void );
8989
90+ void bc_force_free_number (bc_num * num );
91+
9092bc_num _bc_new_num_ex (size_t length , size_t scale , bool persistent );
9193
9294void _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)
8282 BCG (_two_ )-> n_value [0 ] = 2 ;
8383}
8484
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+
8592
8693/* Make a copy of a number! Just increments the reference count! */
8794bc_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