summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2014-12-23 21:47:50 -0500
committerMatthias Clasen <mclasen@redhat.com>2014-12-23 21:47:50 -0500
commit7b9065c2eea5332ec69285ccdc52106a27e25111 (patch)
treec14721467157907131e645b15656bd2b847c6f57 /tests
parent31f502a9ae816fb692716be6b9c68eaa8ee869d3 (diff)
downloadgtk+-7b9065c2eea5332ec69285ccdc52106a27e25111.tar.gz
Avoid a crash in testcalendar
When changing between months, we can get into a situation like 'February 30", which GDate doesn't accept. Don't crash in that case.
Diffstat (limited to 'tests')
-rw-r--r--tests/testcalendar.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/tests/testcalendar.c b/tests/testcalendar.c
index 497901113d..16f04bf5d1 100644
--- a/tests/testcalendar.c
+++ b/tests/testcalendar.c
@@ -67,10 +67,16 @@ calendar_date_to_string (CalendarData *data,
gtk_calendar_get_date (GTK_CALENDAR(data->window),
&year, &month, &day);
- date = g_date_new_dmy (day, month + 1, year);
- g_date_strftime (buffer, buff_len-1, "%x", date);
-
- g_date_free (date);
+ if (g_date_valid_dmy (day, month + 1, year))
+ {
+ date = g_date_new_dmy (day, month + 1, year);
+ g_date_strftime (buffer, buff_len-1, "%x", date);
+ g_date_free (date);
+ }
+ else
+ {
+ g_snprintf (buffer, buff_len - 1, "%d/%d/%d (invalid)", month + 1, day, year);
+ }
}
static void