mirror of
https://github.com/php/php-src.git
synced 2024-11-24 10:24:11 +08:00
Fix memory leak with bcsqrt on number 0<X<1
This commit is contained in:
parent
d033d5c07a
commit
3d2819e491
@ -70,7 +70,6 @@ bc_sqrt (bc_num *num, int scale)
|
||||
|
||||
/* Initialize the variables. */
|
||||
rscale = MAX (scale, (*num)->n_scale);
|
||||
bc_init_num(&guess);
|
||||
bc_init_num(&guess1);
|
||||
bc_init_num(&diff);
|
||||
point5 = bc_new_num (1,1);
|
||||
@ -87,6 +86,7 @@ bc_sqrt (bc_num *num, int scale)
|
||||
else
|
||||
{
|
||||
/* The number is greater than 1. Guess should start at 10^(exp/2). */
|
||||
bc_init_num(&guess);
|
||||
bc_int2num (&guess,10);
|
||||
|
||||
bc_int2num (&guess1,(*num)->n_len);
|
||||
|
@ -9,8 +9,10 @@ bcmath.scale=0
|
||||
echo bcsqrt("9"),"\n";
|
||||
echo bcsqrt("9.444", 2),"\n";
|
||||
echo bcsqrt("1928372132132819737213", 5),"\n";
|
||||
echo bcsqrt("0.5", 5), "\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
3
|
||||
3.07
|
||||
43913234134.28826
|
||||
0.70710
|
||||
|
Loading…
Reference in New Issue
Block a user