summaryrefslogtreecommitdiff
path: root/sql-common
diff options
context:
space:
mode:
authorMattias Jonsson <mattias.jonsson@sun.com>2009-09-01 13:04:56 +0200
committerMattias Jonsson <mattias.jonsson@sun.com>2009-09-01 13:04:56 +0200
commit35ba36d13d5583e05a540ec27d0cfd2588cd055a (patch)
treed2bff3299a5439769dfbf8e34a640850b35ab873 /sql-common
parenta88c86f67f57fe19d4018717822bece5f4e50cfc (diff)
downloadmariadb-git-35ba36d13d5583e05a540ec27d0cfd2588cd055a.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')
-rw-r--r--sql-common/my_time.c5
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));