[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.
This commit is contained in:
Christopher Lam 2023-09-15 22:24:41 +08:00
parent 5a03d9798c
commit a8dffb8559

View File

@ -187,8 +187,8 @@ gnc_gmtime (const time64 *secs)
{
try
{
auto time = static_cast<struct tm*>(calloc(1, sizeof(struct tm)));
GncDateTime gncdt(*secs);
auto time = static_cast<struct tm*>(calloc(1, sizeof(struct tm)));
*time = gncdt.utc_tm();
return time;
}