From a22c69b233e6dd027a3488feb2f5b909ca5681b1 Mon Sep 17 00:00:00 2001 From: Tor Didriksen Date: Wed, 19 May 2010 11:18:59 +0200 Subject: Backport from next-mr-bugfixing of tor.didriksen@sun.com-20100106140051-3j2iuag63eltsr2e Bug #50087 Interval arithmetic for Event_queue_element is not portable. Subtraction of two unsigned months yielded a (very large) positive value. Conversion of this to a signed value was not necessarily well defined. Solution: do the subtraction on signed values. --- sql/event_data_objects.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'sql/event_data_objects.cc') diff --git a/sql/event_data_objects.cc b/sql/event_data_objects.cc index 92e237a17b7..0218092c4c7 100644 --- a/sql/event_data_objects.cc +++ b/sql/event_data_objects.cc @@ -834,8 +834,9 @@ bool get_next_time(const Time_zone *time_zone, my_time_t *next, } else { - long diff_months= (long) (local_now.year - local_start.year)*12 + - (local_now.month - local_start.month); + long diff_months= ((long) local_now.year - (long) local_start.year)*12 + + ((long) local_now.month - (long) local_start.month); + /* Unlike for seconds above, the formula below returns the interval that, when added to the local_start, will give the time in the -- cgit v1.2.1