[balsa] imap-handle.c: Do not leak ImapEnvelope.



commit 4178a422d76589c2e091593fa4a89d9457ad5878
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Thu May 31 19:23:45 2018 -0400

    imap-handle.c: Do not leak ImapEnvelope.
    
    * libbalsa/imap/imap-handle.c (ir_body_type_1part): Do not leak
      ImapEnvelope.

 ChangeLog                   |  5 +++++
 libbalsa/imap/imap-handle.c | 16 ++++++++++++++--
 2 files changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c967b7dc1..84285ec30 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2018-05-31  Peter Bloomfield  <pbloomfield bellsouth net>
+
+       * libbalsa/imap/imap-handle.c (ir_body_type_1part): Do not leak
+       ImapEnvelope.
+
 2018-05-31  Albrecht Dreß <albrecht dress arcor de>
 
        Mitigate EFail vulnerability for Webkit2
diff --git a/libbalsa/imap/imap-handle.c b/libbalsa/imap/imap-handle.c
index 4e23a67fd..bbf6d76f2 100644
--- a/libbalsa/imap/imap-handle.c
+++ b/libbalsa/imap/imap-handle.c
@@ -3977,7 +3977,11 @@ ir_body_type_1part (struct siobuf *sio, ImapBody * body,
       rc = ir_envelope (sio, env);
 #if GMAIL_BUG_20100725
       if (rc == IMR_PARSE)
+        {
+         if (env)
+           imap_envelope_free (env);
           break;
+        }
 #endif /* GMAIL_BUG_20100725 */
       if (rc != IMR_OK)
        {
@@ -3986,14 +3990,22 @@ ir_body_type_1part (struct siobuf *sio, ImapBody * body,
          return rc;
        }
       if (sio_getc (sio) != ' ')
-        return IMR_PROTOCOL;
+       {
+          if (env)
+            imap_envelope_free (env);
+          return IMR_PROTOCOL;
+       }
       if (body)
        {
          b = imap_body_new ();
          body->envelope = env;
        }
       else
-       b = NULL;
+        {
+         b = NULL;
+         if (env)
+           imap_envelope_free (env);
+        }
       rc = ir_body (sio, sio_getc (sio), b, type);
       if (body)
        imap_body_append_child (body, b);


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