1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

out-of-bound array access fixed

This commit is contained in:
serg@serg.mylan
2004-05-11 12:39:00 +02:00
parent 5a0cbfea99
commit 423f37b92b
3 changed files with 22 additions and 2 deletions

View File

@ -105,6 +105,18 @@ select min(a) from t1;
min(a)
-0.010
drop table t1;
create table t1 (a float(200,100), b double(200,100));
insert t1 values (1.0, 2.0);
select * from t1;
a b
1.000000000000000000000000000000 2.000000000000000000000000000000
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` float(200,30) default NULL,
`b` double(200,30) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1 (f float(54));
ERROR 42000: Incorrect column specifier for column 'f'
drop table if exists t1;

View File

@ -54,6 +54,12 @@ select a from t1 order by a;
select min(a) from t1;
drop table t1;
create table t1 (a float(200,100), b double(200,100));
insert t1 values (1.0, 2.0);
select * from t1;
show create table t1;
drop table t1;
# Errors
--error 1063

View File

@ -2307,7 +2307,8 @@ int Field_float::store(double nr)
}
else
{
max_value= (log_10[field_length]-1)/log_10[dec];
uint tmp=min(field_length,array_elements(log_10)-1);
max_value= (log_10[tmp]-1)/log_10[dec];
/*
The following comparison is needed to not get an overflow if nr
is close to FLT_MAX
@ -2607,7 +2608,8 @@ int Field_double::store(double nr)
}
else
{
max_value= (log_10[field_length]-1)/log_10[dec];
uint tmp=min(field_length,array_elements(log_10)-1);
max_value= (log_10[tmp]-1)/log_10[dec];
if (fabs(nr) < DBL_MAX/10.0e+32)
nr= floor(nr*log_10[dec]+0.5)/log_10[dec];
}