SF.net SVN: geany: [1104] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Sat Dec 16 17:00:41 UTC 2006


Revision: 1104
          http://svn.sourceforge.net/geany/?rev=1104&view=rev
Author:   ntrel
Date:     2006-12-16 09:00:41 -0800 (Sat, 16 Dec 2006)

Log Message:
-----------
Fix memory leak in utils_check_disk_status().

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/utils.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-12-15 18:33:29 UTC (rev 1103)
+++ trunk/ChangeLog	2006-12-16 17:00:41 UTC (rev 1104)
@@ -1,3 +1,9 @@
+2006-12-16  Nick Treleaven  <nick.treleaven at btinternet.com>
+
+ * src/utils.c:
+   Fix memory leak in utils_check_disk_status().
+
+
 2006-12-15  Enrico Tröger  <enrico.troeger at uvena.de>
 
  * src/main.c, src/sci_cb.c, src/sci_cb.h, src/symbols.c,

Modified: trunk/src/utils.c
===================================================================
--- trunk/src/utils.c	2006-12-15 18:33:29 UTC (rev 1103)
+++ trunk/src/utils.c	2006-12-16 17:00:41 UTC (rev 1104)
@@ -329,6 +329,7 @@
 	struct stat st;
 	time_t t;
 	gchar *locale_filename;
+	gboolean ret = FALSE;
 
 	if (idx == -1 || doc_list[idx].file_name == NULL) return FALSE;
 
@@ -337,15 +338,15 @@
 	if (doc_list[idx].last_check > (t - GEANY_CHECK_FILE_DELAY)) return FALSE;
 
 	locale_filename = utils_get_locale_from_utf8(doc_list[idx].file_name);
-	if (stat(locale_filename, &st) != 0) return FALSE;
-
-	if (doc_list[idx].mtime > t || st.st_mtime > t)
+	if (stat(locale_filename, &st) != 0)
 	{
+		// TODO: warn user file on disk is missing
+	}
+	else if (doc_list[idx].mtime > t || st.st_mtime > t)
+	{
 		geany_debug("Strange: Something is wrong with the time stamps.");
-		return FALSE;
 	}
-
-	if (doc_list[idx].mtime < st.st_mtime)
+	else if (doc_list[idx].mtime < st.st_mtime)
 	{
 		gchar *basename = g_path_get_basename(doc_list[idx].file_name);
 
@@ -361,9 +362,10 @@
 			doc_list[idx].mtime = st.st_mtime;
 
 		g_free(basename);
-		return TRUE; //file has changed
+		ret = TRUE; // file has changed
 	}
-	return FALSE;
+	g_free(locale_filename);
+	return ret;
 }
 
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list