gnucash stable: Multiple changes pushed
Christopher Lam
clam at code.gnucash.org
Mon Mar 16 21:21:31 EDT 2026
Updated via https://github.com/Gnucash/gnucash/commit/3d4f19f8 (commit)
via https://github.com/Gnucash/gnucash/commit/06c7f4bd (commit)
from https://github.com/Gnucash/gnucash/commit/b521f21a (commit)
commit 3d4f19f830d70362b51d2880c8a615ed890f6229
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sun Mar 15 13:40:18 2026 +0800
[gnc-date.cpp] fix ifdef conditional, and comment
diff --git a/libgnucash/engine/gnc-date.cpp b/libgnucash/engine/gnc-date.cpp
index cd5e64ba3f..f9fc8b2663 100644
--- a/libgnucash/engine/gnc-date.cpp
+++ b/libgnucash/engine/gnc-date.cpp
@@ -241,7 +241,7 @@ gnc_timegm (struct tm* time)
*time = static_cast<struct tm>(gncdt);
time->tm_sec -= gncdt.offset();
normalize_struct_tm(time);
-#ifdef HAVE_STRUcT_TM_GMTOFF
+#ifdef HAVE_STRUCT_TM_GMTOFF
time->tm_gmtoff = 0;
#endif
return static_cast<time64>(gncdt) - gncdt.offset();
@@ -409,7 +409,7 @@ time64CanonicalDayTime (time64 t)
return gnc_mktime (&tm);
}
-/* NB: month is 1-12, year is 0001 - 9999. */
+/* NB: month is 0-11, year is 0001 - 9999. */
int gnc_date_get_last_mday (int month, int year)
{
static int last_day_of_month[12] =
commit 06c7f4bd3fcd75a967e031c9c798fde858341aac
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sun Mar 15 13:39:09 2026 +0800
[gnc-datetime.cpp] fast_iso8601_utc_parse: precompute length
because std::from_chars is UB if the string is less than 4 bytes
therefore end_ptr would point to unallocated memory.
diff --git a/libgnucash/engine/gnc-datetime.cpp b/libgnucash/engine/gnc-datetime.cpp
index c648a51d2d..f816cec0d4 100644
--- a/libgnucash/engine/gnc-datetime.cpp
+++ b/libgnucash/engine/gnc-datetime.cpp
@@ -381,13 +381,12 @@ static std::optional<PTime>
fast_iso8601_utc_parse (const char* str)
{
int32_t year, month, mday, hour, min, sec;
-
- // parse the first 4 bytes into year
- if (!str || !parse_chars_into_num (str, str + 4, year))
- return {};
+ const size_t len = str ? strnlen (str, 26) : 0;
// parse iso-8601 utc format "YYYY-MM-DD HH:MM:SS +0000"
- if (str[4] == '-' &&
+ constexpr size_t expanded_iso_string_len = 25;
+ if (len == expanded_iso_string_len &&
+ parse_chars_into_num (str, str + 4, year) && str[ 4] == '-' &&
parse_chars_into_num (str + 5, str + 7, month) && str[ 7] == '-' &&
parse_chars_into_num (str + 8, str + 10, mday) && str[10] == ' ' &&
parse_chars_into_num (str + 11, str + 13, hour) && str[13] == ':' &&
@@ -400,12 +399,14 @@ fast_iso8601_utc_parse (const char* str)
}
// parse compressed iso-8601 format "YYYYMMDDHHMMSS"
- if (parse_chars_into_num (str + 4, str + 6, month) &&
+ constexpr size_t compact_iso_string_len = 14;
+ if (len == compact_iso_string_len &&
+ parse_chars_into_num (str, str + 4, year) &&
+ parse_chars_into_num (str + 4, str + 6, month) &&
parse_chars_into_num (str + 6, str + 8, mday) &&
parse_chars_into_num (str + 8, str + 10, hour) &&
parse_chars_into_num (str + 10, str + 12, min) &&
- parse_chars_into_num (str + 12, str + 14, sec) &&
- str[14] == '\0')
+ parse_chars_into_num (str + 12, str + 14, sec))
{
return PTime (boost::gregorian::date (year, month, mday),
boost::posix_time::time_duration (hour, min, sec));
Summary of changes:
libgnucash/engine/gnc-date.cpp | 4 ++--
libgnucash/engine/gnc-datetime.cpp | 17 +++++++++--------
2 files changed, 11 insertions(+), 10 deletions(-)
More information about the gnucash-changes
mailing list