From 959c04d0ceff552c5d9a551f79702c33bdac16a5 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Thu, 14 Mar 2013 20:15:08 -0400 Subject: Add argument checks to weekday functions. --- e-util/e-misc-utils.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/e-util/e-misc-utils.c b/e-util/e-misc-utils.c index 0f350999f5..776027da09 100644 --- a/e-util/e-misc-utils.c +++ b/e-util/e-misc-utils.c @@ -1596,6 +1596,10 @@ GDateWeekday e_weekday_add_days (GDateWeekday weekday, guint n_days) { + g_return_val_if_fail ( + g_date_valid_weekday (weekday), + G_DATE_BAD_WEEKDAY); + n_days %= 7; /* Weekdays repeat every 7 days. */ while (n_days-- > 0) @@ -1617,6 +1621,10 @@ GDateWeekday e_weekday_subtract_days (GDateWeekday weekday, guint n_days) { + g_return_val_if_fail ( + g_date_valid_weekday (weekday), + G_DATE_BAD_WEEKDAY); + n_days %= 7; /* Weekdays repeat every 7 days. */ while (n_days-- > 0) @@ -1640,6 +1648,9 @@ e_weekday_get_days_between (GDateWeekday weekday1, { guint n_days = 0; + g_return_val_if_fail (g_date_valid_weekday (weekday1), 0); + g_return_val_if_fail (g_date_valid_weekday (weekday2), 0); + while (weekday1 != weekday2) { n_days++; weekday1 = e_weekday_get_next (weekday1); -- cgit v1.2.3