0.9.0claws44
authorChristoph Hohmann <reboot@gmx.ch>
Wed, 18 Jun 2003 15:32:14 +0000 (15:32 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Wed, 18 Jun 2003 15:32:14 +0000 (15:32 +0000)
* src/imap.c
        fix memory leak in imap_cmd_ok()

ChangeLog.claws
configure.ac
src/imap.c

index 013377e..5d15d74 100644 (file)
@@ -1,3 +1,8 @@
+2003-06-18 [christoph] 0.9.0claws44
+
+       * src/imap.c
+               fix memory leak in imap_cmd_ok()
+
 2003-06-18 [christoph] 0.9.0claws43
 
        * src/folder.c
index f190c51..936c1a1 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws43
+EXTRA_VERSION=claws44
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 410dd4e..f20b3cc 100644 (file)
@@ -593,7 +593,6 @@ IMAPSession *imap_session_new(const PrefsAccount *account)
        IMAPSession *session;
        SockInfo *imap_sock;
        gushort port;
-       gboolean is_preauth;
 
 #ifdef USE_OPENSSL
        /* FIXME: IMAP over SSL only... */ 
@@ -644,7 +643,7 @@ IMAPSession *imap_session_new(const PrefsAccount *account)
        session->capability = NULL;
 
        session->mbox = NULL;
-       session->authenticated = is_preauth;
+       session->authenticated = FALSE;
        session->cmd_count = 0;
 
        /* Only need to log in if the connection was not PREAUTH */
@@ -669,7 +668,7 @@ IMAPSession *imap_session_new(const PrefsAccount *account)
                }
 
                imap_free_capabilities(session);
-               session->authenticated = is_preauth;
+               session->authenticated = FALSE;
                session->cmd_count = 1;
 
                if (imap_greeting(session) != IMAP_SUCCESS) {
@@ -679,7 +678,7 @@ IMAPSession *imap_session_new(const PrefsAccount *account)
        }
 #endif
        log_message("IMAP connection is %s-authenticated\n",
-                   (is_preauth) ? "pre" : "un");
+                   (session->authenticated) ? "pre" : "un");
 
        return session;
 }
@@ -2762,7 +2761,7 @@ static gint imap_cmd_expunge(IMAPSession *session)
 
 static gint imap_cmd_ok(IMAPSession *session, GPtrArray *argbuf)
 {
-       gint ok;
+       gint ok = IMAP_SUCCESS;
        gchar *buf;
        gint cmd_num;
        gchar *data;
@@ -2772,40 +2771,36 @@ static gint imap_cmd_ok(IMAPSession *session, GPtrArray *argbuf)
                // make sure data is long enough for any substring of buf
                data = alloca(strlen(buf) + 1);
 
+               // untagged line read
                if (buf[0] == '*' && buf[1] == ' ') {
                        gint num;
                        if (argbuf)
                                g_ptr_array_add(argbuf, g_strdup(buf + 2));
 
-                       if (sscanf(buf + 2, "%d %s", &num, data) < 2)
-                               continue;
-
-                       if (!strcmp(data, "EXISTS")) {
-                               session->exists = num;
-                               session->folder_content_changed = TRUE;
-                       }
+                       if (sscanf(buf + 2, "%d %s", &num, data) >= 2) {
+                               if (!strcmp(data, "EXISTS")) {
+                                       session->exists = num;
+                                       session->folder_content_changed = TRUE;
+                               }
 
-                       if(!strcmp(data, "EXPUNGE")) {
-                               session->exists--;
-                               session->folder_content_changed = TRUE;
+                               if(!strcmp(data, "EXPUNGE")) {
+                                       session->exists--;
+                                       session->folder_content_changed = TRUE;
+                               }
                        }
-
-                       continue;
-               }
-
-               if (sscanf(buf, "%d %s", &cmd_num, data) < 2) {
-                       g_free(buf);
-                       return IMAP_ERROR;
-               } else if (cmd_num == session->cmd_count &&
-                        !strcmp(data, "OK")) {
+               // tagged line with correct tag and OK response found
+               } else if ((sscanf(buf, "%d %s", &cmd_num, data) >= 2) &&
+                          (cmd_num == session->cmd_count) &&
+                          !strcmp(data, "OK")) {
                        if (argbuf)
                                g_ptr_array_add(argbuf, g_strdup(buf));
-                       g_free(buf);
-                       return IMAP_SUCCESS;
+                       break;
+               // everything else
                } else {
-                       g_free(buf);
-                       return IMAP_ERROR;
+                       ok = IMAP_ERROR;
+                       break;
                }
+               g_free(buf);
        }
        g_free(buf);