From a8dffb8559fd19f93bfe842c2bf4f008289b7eb8 Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Fri, 15 Sep 2023 22:24:41 +0800 Subject: [PATCH] [gnc-date.cpp] don't alloc tm* unless GncDateTime() succeeds because GncDateTime() may throw an exception, in which case time will leak. mainly leaks in test suite. --- libgnucash/engine/gnc-date.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libgnucash/engine/gnc-date.cpp b/libgnucash/engine/gnc-date.cpp index d7ae1a3dca..c44912efa7 100644 --- a/libgnucash/engine/gnc-date.cpp +++ b/libgnucash/engine/gnc-date.cpp @@ -187,8 +187,8 @@ gnc_gmtime (const time64 *secs) { try { - auto time = static_cast(calloc(1, sizeof(struct tm))); GncDateTime gncdt(*secs); + auto time = static_cast(calloc(1, sizeof(struct tm))); *time = gncdt.utc_tm(); return time; }