From d1a2d70be91fa72c75b6a98c9645529446f1c407 Mon Sep 17 00:00:00 2001 From: Christian Stimming Date: Fri, 20 Sep 2013 21:09:21 +0000 Subject: [PATCH] Fix memory leak due to missing free after gnc_ctime(). Also, remove the trailing newline from the returned time string, as this is rather unexpected here. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@23183 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/engine/Transaction.c | 3 ++- src/libqof/qof/gnc-date.c | 2 +- src/libqof/qof/test/test-gnc-date.c | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/engine/Transaction.c b/src/engine/Transaction.c index 940859c258..d38f4d70fa 100644 --- a/src/engine/Transaction.c +++ b/src/engine/Transaction.c @@ -1791,8 +1791,9 @@ xaccTransSetDateInternal(Transaction *trans, Timespec *dadate, Timespec val) { time64 secs = (time64) val.tv_sec; gchar *tstr = gnc_ctime (&secs); - PINFO ("addr=%p set date to %" G_GUINT64_FORMAT ".%09ld %s", + PINFO ("addr=%p set date to %" G_GUINT64_FORMAT ".%09ld %s\n", trans, val.tv_sec, val.tv_nsec, tstr ? tstr : "(null)"); + g_free(tstr); } *dadate = val; diff --git a/src/libqof/qof/gnc-date.c b/src/libqof/qof/gnc-date.c index ecc951cb96..be70c68b89 100644 --- a/src/libqof/qof/gnc-date.c +++ b/src/libqof/qof/gnc-date.c @@ -438,7 +438,7 @@ gchar* gnc_ctime (const time64 *secs) { GDateTime *gdt = gnc_g_date_time_new_from_unix_local (*secs); - gchar *string = g_date_time_format (gdt, "%a %b %e %H:%M:%S %Y\n"); + gchar *string = g_date_time_format (gdt, "%a %b %e %H:%M:%S %Y"); g_date_time_unref (gdt); return string; } diff --git a/src/libqof/qof/test/test-gnc-date.c b/src/libqof/qof/test/test-gnc-date.c index 5d24cb1309..0bac35d318 100644 --- a/src/libqof/qof/test/test-gnc-date.c +++ b/src/libqof/qof/test/test-gnc-date.c @@ -293,7 +293,7 @@ test_gnc_ctime (void) GDateTime *gdt = gncdt.new_from_unix_local (secs[ind]); gchar* datestr = gnc_ctime (&secs[ind]); g_assert_cmpstr (datestr, ==, - g_date_time_format (gdt, "%a %b %e %H:%M:%S %Y\n")); + g_date_time_format (gdt, "%a %b %e %H:%M:%S %Y")); g_date_time_unref (gdt); g_free (datestr); }