From: Andrea Zagli Date: Mon, 1 May 2017 10:40:08 +0000 (+0200) Subject: Possible glib bug: valid date with values out of range. X-Git-Tag: v0.0.2~1^2 X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=6fad917699e9196d8f600b0119650f1079bdc011;p=libzakutils 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. --- 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;