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
This commit is contained in:
Christian Stimming 2013-09-20 21:09:21 +00:00
parent b73c10b8b9
commit d1a2d70be9
3 changed files with 4 additions and 3 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -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);
}