[evolution-data-server] Fix memory leak introduced yesterday in imapx QRESYNC



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

    Fix memory leak introduced yesterday in imapx QRESYNC
    
    Commit 0c866faf ("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 30a8ecd..e7c78e9 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -2602,14 +2602,13 @@ imapx_select (CamelIMAPXServer *is,
 		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(is->tagprefix, "SELECT QRESYNC %" G_GUINT64_FORMAT
 			  " %" G_GUINT64_FORMAT "\n",
 			  ifolder->uidvalidity_on_server, isum->modseq);
@@ -2619,8 +2618,7 @@ imapx_select (CamelIMAPXServer *is,
 						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]