r23183 - gnucash/trunk/src - Fix memory leak due to missing free after gnc_ctime().
Christian Stimming
cstim at code.gnucash.org
Fri Sep 20 17:09:21 EDT 2013
Author: cstim
Date: 2013-09-20 17:09:21 -0400 (Fri, 20 Sep 2013)
New Revision: 23183
Trac: http://svn.gnucash.org/trac/changeset/23183
Modified:
gnucash/trunk/src/engine/Transaction.c
gnucash/trunk/src/libqof/qof/gnc-date.c
gnucash/trunk/src/libqof/qof/test/test-gnc-date.c
Log:
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.
Modified: gnucash/trunk/src/engine/Transaction.c
===================================================================
--- gnucash/trunk/src/engine/Transaction.c 2013-09-20 21:09:06 UTC (rev 23182)
+++ gnucash/trunk/src/engine/Transaction.c 2013-09-20 21:09:21 UTC (rev 23183)
@@ -1791,8 +1791,9 @@
{
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;
Modified: gnucash/trunk/src/libqof/qof/gnc-date.c
===================================================================
--- gnucash/trunk/src/libqof/qof/gnc-date.c 2013-09-20 21:09:06 UTC (rev 23182)
+++ gnucash/trunk/src/libqof/qof/gnc-date.c 2013-09-20 21:09:21 UTC (rev 23183)
@@ -438,7 +438,7 @@
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;
}
Modified: gnucash/trunk/src/libqof/qof/test/test-gnc-date.c
===================================================================
--- gnucash/trunk/src/libqof/qof/test/test-gnc-date.c 2013-09-20 21:09:06 UTC (rev 23182)
+++ gnucash/trunk/src/libqof/qof/test/test-gnc-date.c 2013-09-20 21:09:21 UTC (rev 23183)
@@ -293,7 +293,7 @@
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);
}
More information about the gnucash-changes
mailing list