r22199 - gnucash/trunk/src/backend/xml - Fix memory leaks found by unit tests/valgrind
Phil Longstaff
plongstaff at code.gnucash.org
Mon May 21 18:36:16 EDT 2012
Author: plongstaff
Date: 2012-05-21 18:36:15 -0400 (Mon, 21 May 2012)
New Revision: 22199
Trac: http://svn.gnucash.org/trac/changeset/22199
Modified:
gnucash/trunk/src/backend/xml/gnc-backend-xml.c
Log:
Fix memory leaks found by unit tests/valgrind
Return value of g_build_filename() needs to be freed.
Modified: gnucash/trunk/src/backend/xml/gnc-backend-xml.c
===================================================================
--- gnucash/trunk/src/backend/xml/gnc-backend-xml.c 2012-05-21 22:12:32 UTC (rev 22198)
+++ gnucash/trunk/src/backend/xml/gnc-backend-xml.c 2012-05-21 22:36:15 UTC (rev 22199)
@@ -882,11 +882,17 @@
/* Only evaluate files associated with the current data file. */
if (!g_str_has_prefix(name, be->fullpath))
+ {
+ g_free(name);
continue;
+ }
/* Never remove the current data file itself */
if (g_strcmp0(name, be->fullpath) == 0)
+ {
+ g_free(name);
continue;
+ }
/* Test if the current file is a lock file */
if (g_str_has_suffix(name, ".LNK"))
@@ -901,6 +907,7 @@
g_unlink(name);
}
+ g_free(name);
continue;
}
@@ -932,7 +939,10 @@
g_free(expression);
if (!got_date_stamp) /* Not a gnucash created file after all... */
+ {
+ g_free(name);
continue;
+ }
}
/* The file is a backup or log file. Check the user's retention preference
@@ -950,7 +960,10 @@
/* Is the backup file old enough to delete */
if (g_stat(name, &statbuf) != 0)
+ {
+ g_free(name);
continue;
+ }
days = (int)(difftime(now, statbuf.st_mtime) / 86400);
PINFO ("file retention = %d days", be->file_retention_days);
More information about the gnucash-changes
mailing list