From 6fad917699e9196d8f600b0119650f1079bdc011 Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Mon, 1 May 2017 12:40:08 +0200 Subject: [PATCH] Possible glib bug: valid date with values out of range. The function g_date_time_new_local return a valida date also if passed values for month/day are out of range. --- src/datetime.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/datetime.c b/src/datetime.c index cad5883..1c3eb4a 100644 --- a/src/datetime.c +++ b/src/datetime.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Andrea Zagli + * Copyright (C) 2015-2017 Andrea Zagli * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -497,6 +497,19 @@ GDateTime hour, minute, seconds); + + /* possible glib bug + * returns a valid date also if day/month values are out of range */ + if (g_date_time_get_year (ret) != year + || g_date_time_get_month (ret) != month + || g_date_time_get_day_of_month (ret) != day + || g_date_time_get_hour (ret) != hour + || g_date_time_get_minute (ret) != minute + || g_date_time_get_seconds (ret) != seconds) + { + g_date_time_unref (ret); + ret = NULL; + } } return ret; -- 2.49.0