diff options
author | Mattias Jonsson <mattias.jonsson@sun.com> | 2009-09-01 13:04:56 +0200 |
---|---|---|
committer | Mattias Jonsson <mattias.jonsson@sun.com> | 2009-09-01 13:04:56 +0200 |
commit | 82a5cfa5ab5eb62b5de3d440cc842a07643cb0bb (patch) | |
tree | d2bff3299a5439769dfbf8e34a640850b35ab873 /sql-common/my_time.c | |
parent | 6bc9610022dc2c14a4aa291f3ff04e7f55693603 (diff) | |
download | mariadb-git-82a5cfa5ab5eb62b5de3d440cc842a07643cb0bb.tar.gz |
Post fix patch for bug#20577 and bug#46362.
On 64-bits machines the calculation gets the wrong types and results
in very large numbers. Fixed by explicitly cast month to (int)
Diffstat (limited to 'sql-common/my_time.c')
-rw-r--r-- | sql-common/my_time.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/sql-common/my_time.c b/sql-common/my_time.c index 18358519023..2ec1fc253a7 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -775,11 +775,12 @@ long calc_daynr(uint year,uint month,uint day) if (y == 0 && month == 0 && day == 0) DBUG_RETURN(0); /* Skip errors */ - delsum= (long) (365L * y+ 31*(month-1) +day); + /* Cast to int to be able to handle month == 0 */ + delsum= (long) (365 * y + 31 *((int) month - 1) + (int) day); if (month <= 2) y--; else - delsum-= (long) (month*4+23)/10; + delsum-= (long) ((int) month * 4 + 23) / 10; temp=(int) ((y/100+1)*3)/4; DBUG_PRINT("exit",("year: %d month: %d day: %d -> daynr: %ld", y+(month <= 2),month,day,delsum+y/4-temp)); |