[evolution-rss] fix some reported memleaks



commit 08e25c4e55060faf02b95778df2e549e044df0ce
Author: Lucian Langa <lucilanga gnome org>
Date:   Fri Jul 9 18:01:56 2010 +0300

    fix some reported memleaks

 src/dbus.c               |    1 +
 src/misc.c               |    2 +-
 src/rss-config-factory.c |    1 +
 src/rss-config.c         |   20 +++++++++-----------
 src/rss.c                |   33 +++++++++++++++++----------------
 5 files changed, 29 insertions(+), 28 deletions(-)
---
diff --git a/src/dbus.c b/src/dbus.c
index 7480ae1..c51675c 100644
--- a/src/dbus.c
+++ b/src/dbus.c
@@ -141,6 +141,7 @@ filter_function (DBusConnection *connection, DBusMessage *message, void *user_da
 			g_print("Feed received, but error getting message: %s\n", error.message);
 			dbus_error_free (&error);
 		}
+		g_free(feed);
 		return DBUS_HANDLER_RESULT_HANDLED;
 	}
 	else if (dbus_message_is_signal (message, DBUS_INTERFACE, "ping")) {
diff --git a/src/misc.c b/src/misc.c
index f405a49..5710e58 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -582,10 +582,10 @@ feed_remove_status_line(gchar *file_name, gchar *needle)
 			}
 		}
 		fclose(fr);
-		fclose(fw);
 		g_unlink(file_name);
 		g_rename(tmp, file_name);
 	}
+	fclose(fw);
 	g_free(tmpneedle);
 }
 
diff --git a/src/rss-config-factory.c b/src/rss-config-factory.c
index 4cac7bb..0f06fb0 100644
--- a/src/rss-config-factory.c
+++ b/src/rss-config-factory.c
@@ -3050,6 +3050,7 @@ e_plugin_lib_get_configure_widget (EPlugin *epl)
 	}
 #else
 	g_warning("gtk too old! cannot create ui file. need >= 2.14\n");
+	g_free(ui);
 	// and not very interesed to back port this
 	return NULL;
 #endif
diff --git a/src/rss-config.c b/src/rss-config.c
index 9ab1225..86c7a84 100644
--- a/src/rss-config.c
+++ b/src/rss-config.c
@@ -559,13 +559,12 @@ get_main_folder(void)
 	g_free(feed_dir);
 	if (g_file_test(feed_file, G_FILE_TEST_EXISTS)) {
 		FILE *f = fopen(feed_file, "r");
-		if (f) {
-			if (fgets(mf, 511, f) != NULL) {
-				fclose(f);
-				g_free(feed_file);
-				return g_strdup(mf);
-			}
+		if (f && fgets(mf, 511, f) != NULL) {
+			fclose(f);
+			g_free(feed_file);
+			return g_strdup(mf);
 		}
+		fclose(f);
 	}
 	g_free(feed_file);
 	return g_strdup(DEFAULT_FEEDS_FOLDER);
@@ -641,10 +640,10 @@ migrate_crc_md5(const char *name, gchar *url)
 				(void)fseek(fw, 0L, SEEK_SET);
 				fwrite(rfeed, strlen(rfeed), 1, fw);
 			}
-			fclose(fw);
 			unlink(feed_name);
 		}
-		fclose(fr);
+		if (fr) fclose(fr);
+		if (fw)	fclose(fw);
 	}
 	g_free(feed_name);
 	feed_name = g_build_path(G_DIR_SEPARATOR_S, feed_dir, crc2, NULL);
@@ -659,11 +658,10 @@ migrate_crc_md5(const char *name, gchar *url)
 				(void)fseek(fw, 0L, SEEK_SET);
 				fwrite(rfeed, strlen(rfeed), 1, fw);
 			}
-			fclose(fw);
 			unlink(feed_name);
 		}
-		fclose(fr);
-
+		if (fr) fclose(fr);
+		if (fw)	fclose(fw);
 	}
 
 	g_free(feed_name);
diff --git a/src/rss.c b/src/rss.c
index 1413511..e7ffa63 100644
--- a/src/rss.c
+++ b/src/rss.c
@@ -835,6 +835,7 @@ proxy_auth_dialog(gchar *title, gchar *user, gchar *pass)
 	auth_info->pass = pass;
 	dialog = create_user_pass_dialog(auth_info);
 	result = gtk_dialog_run(GTK_DIALOG(dialog));
+	/*LEAK g_free(auth_info);*/
 	return TRUE;
 }
 
@@ -3434,15 +3435,15 @@ generic_finish_feed(rfMessage *msg, gpointer user_data)
 			_("Error while parsing feed."),
 			tmsg);
 		g_free(tmsg);
-		goto out;
+		goto cleanup;
 	}
 
 	if (msg->status_code == SOUP_STATUS_CANCELLED)
-		goto out;
+		goto cleanup;
 
 	if (!deleted) {
 		if (!user_data || !lookup_key(user_data))
-			goto out;
+			goto cleanup;
 		r->uri =  g_hash_table_lookup(
 				rf->hr, lookup_key(user_data));
 
@@ -3469,18 +3470,9 @@ generic_finish_feed(rfMessage *msg, gpointer user_data)
 			if (g_hash_table_lookup(rf->hrdel_feed, lookup_key(user_data)))
 				get_feed_age(r, user_data);
 		}
-		if (r->cache)
-			xmlFreeDoc(r->cache);
-		if (r->type)
-			g_free(r->type);
-		if (r->version)
-			g_free(r->version);
-		if (r->uids)
-			g_array_free(r->uids, TRUE);
 	}
 	//ftotal+=r->total;
 	update_sr_message();
-	g_free(r);
 	g_string_free(response, 1);
 
 //tout:
@@ -3519,8 +3511,16 @@ generic_finish_feed(rfMessage *msg, gpointer user_data)
 		rf->info = NULL;
 	}
 #endif
-out:
-	if (chn_name) { //user_data
+cleanup:if (r->cache)
+		xmlFreeDoc(r->cache);
+	if (r->type)
+		g_free(r->type);
+	if (r->version)
+		g_free(r->version);
+	if (r->uids)
+		g_array_free(r->uids, TRUE);
+	g_free(r);
+out:	if (chn_name) { //user_data
 		//not sure why it dies here
 		if (!rf->cancel && !rf->cancel_all)
 			g_free(chn_name); //user_data
@@ -3991,12 +3991,11 @@ sync_folders(void)
 		return;
 
 	if (!g_hash_table_size(rf->feed_folders))
-		return;
+		goto exit;
 
 	g_hash_table_foreach(rf->feed_folders,
 		(GHFunc)write_feeds_folder_line,
 		(gpointer *)f);
-	fclose(f);
 	g_free(feed_file);
 	g_hash_table_destroy(rf->reversed_feed_folders);
 	rf->reversed_feed_folders = g_hash_table_new_full(g_str_hash,
@@ -4006,6 +4005,8 @@ sync_folders(void)
 	g_hash_table_foreach(rf->feed_folders,
 			(GHFunc)populate_reversed,
 			rf->reversed_feed_folders);
+exit:	fclose(f);
+	return;
 }
 
 /*construct feed_folders file with rename allocation



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]