summaryrefslogtreecommitdiffstats
path: root/pop.c
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2022-08-30 15:31:24 -0700
committerKevin McCarthy <kevin@8t8.us>2022-08-30 15:31:24 -0700
commite43a42bfdbdbd968f15dbdf00bf6c04bedcf1ca3 (patch)
tree0fd533e01e1014dd5bcde47438cb38528f2d0c5c /pop.c
parentc46db2be0e08ca59760cb26ad0e00d3a3970bc08 (diff)
Ensure pop_data is freed for mailbox and fetch-mail usage.
<fetch-mail> was only free'ing the container and not the auth_list or timestamp used in authentication. Mailbox usage was never free'ing the pop_data object. Create a pop_free_pop_data() helper and use that in <fetch-mail> usage where the pop_data was being free'd before. Since the pop code always allocates and assigns a new pop_data object after each mutt_conn_find(), add a call to pop_close_mailbox() too. Just to make sure, reset connection->data before free'ing the pop_data in each case.
Diffstat (limited to 'pop.c')
-rw-r--r--pop.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/pop.c b/pop.c
index 3219e6be..4eed4edf 100644
--- a/pop.c
+++ b/pop.c
@@ -516,6 +516,20 @@ static void pop_clear_cache (POP_DATA *pop_data)
}
}
+static void pop_free_pop_data (POP_DATA **p_pop_data)
+{
+ POP_DATA *pop_data;
+
+ if (!p_pop_data || !*p_pop_data)
+ return;
+
+ pop_data = *p_pop_data;
+
+ FREE (&pop_data->auth_list);
+ FREE (&pop_data->timestamp);
+ FREE (p_pop_data); /* __FREE_CHECKED__ */
+}
+
/* close POP mailbox */
int pop_close_mailbox (CONTEXT *ctx)
{
@@ -534,10 +548,15 @@ int pop_close_mailbox (CONTEXT *ctx)
pop_data->clear_cache = 1;
pop_clear_cache (pop_data);
+ mutt_bcache_close (&pop_data->bcache);
+
if (!pop_data->conn->data)
mutt_socket_free (pop_data->conn);
+ else
+ pop_data->conn->data = NULL;
- mutt_bcache_close (&pop_data->bcache);
+ pop_free_pop_data (&pop_data);
+ ctx->data = NULL;
return 0;
}
@@ -894,7 +913,7 @@ void pop_fetch_mail (void)
if (pop_open_connection (pop_data) < 0)
{
mutt_socket_free (pop_data->conn);
- FREE (&pop_data);
+ pop_free_pop_data (&pop_data);
return;
}
@@ -1002,13 +1021,15 @@ finish:
if (pop_query (pop_data, buffer, sizeof (buffer)) == -1)
goto fail;
mutt_socket_close (conn);
- FREE (&pop_data);
+ conn->data = NULL;
+ pop_free_pop_data (&pop_data);
return;
fail:
mutt_error _("Server closed connection!");
mutt_socket_close (conn);
- FREE (&pop_data);
+ conn->data = NULL;
+ pop_free_pop_data (&pop_data);
}
struct mx_ops mx_pop_ops = {