[evolution-data-server/gnome-2-32] Fix memory leak recently introduced in imapx QRESYNC



commit 7d6978013b4f89d4669f80ef049f15d2790ad42b
Author: David Woodhouse <David Woodhouse intel com>
Date:   Fri Nov 12 11:15:11 2010 +0000

    Fix memory leak recently introduced in imapx QRESYNC
    
    Commit e02cb958 ("Fix QRESYNC protocol violation (RH #648082))
    introduced a potential leak of the 'lastuid' and 'firstuid' strings.
    
    It would almost never happen, because it would require that we're
    selecting a folder on a QRESYNC-capable server where we *have*
    previously seen messages in that folder, but for some reason we don't
    have a record of the uidvalidity and previous modification sequence
    (modseq). The only time that's ever likely to happen is perhaps the
    first time we connect to the server after QRESYNC is enabled. But that's
    no excuse.
    
    Fix this by simplifying the logic. There's no point in using QRESYNC if
    our local cache knows of no messages in the folder *anyway*, so remove
    that separate check and merge the 'if (total)' part into the existing
    condition for actually issuing QRESYNC.
    
    Spotted by Bojan Smojver.

 camel/providers/imapx/camel-imapx-server.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index cd706f6..87b1745 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -2552,14 +2552,13 @@ imapx_select (CamelIMAPXServer *is, CamelFolder *folder, gboolean forced, GError
 		CamelIMAPXSummary *isum = (CamelIMAPXSummary *)folder->summary;
 		CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *)folder;
 		gint total = camel_folder_summary_count (folder->summary);
-		gchar *firstuid = NULL, *lastuid = NULL;
+		gchar *firstuid, *lastuid;
+
+		if (total && isum->modseq && ifolder->uidvalidity_on_server) {
 
-		if (total) {
 			firstuid = camel_folder_summary_uid_from_index (folder->summary, 0);
 			lastuid = camel_folder_summary_uid_from_index (folder->summary, total - 1);
-		}
 
-		if (isum->modseq && ifolder->uidvalidity_on_server) {
 			c(printf("SELECT QRESYNC %" G_GUINT64_FORMAT
 				 " %" G_GUINT64_FORMAT "\n",
 				 ifolder->uidvalidity_on_server, isum->modseq));
@@ -2568,8 +2567,7 @@ imapx_select (CamelIMAPXServer *is, CamelFolder *folder, gboolean forced, GError
 						G_GUINT64_FORMAT " %s:%s",
 						ifolder->uidvalidity_on_server,
 						isum->modseq,
-						firstuid?firstuid:"1",
-						lastuid?lastuid:"1");
+						firstuid, lastuid);
 
 			g_free (firstuid);
 			g_free (lastuid);



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