From f5532b4a7485a2c098a367917952a7518de8d408 Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Mon, 21 Jun 2004 03:19:58 +0000 Subject: * mailbox/pop/pop3_lista.c: Destroy the list on error. * mailbox/pop/pop3_uidla.c: Destroy the list on error. --- mailbox/pop/pop3_lista.c | 12 +++++++++--- mailbox/pop/pop3_uidla.c | 12 ++++++++++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/mailbox/pop/pop3_lista.c b/mailbox/pop/pop3_lista.c index 0039081a7..94464f055 100644 --- a/mailbox/pop/pop3_lista.c +++ b/mailbox/pop/pop3_lista.c @@ -1,5 +1,5 @@ /* GNU Mailutils -- a suite of utilities for electronic mail - Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2001, 2004 Free Software Foundation, Inc. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -65,12 +65,18 @@ mu_pop3_list_all (mu_pop3_t pop3, list_t *plist) But do not use the stack and malloc. */ char *lista; size_t n = 0; - + lista = malloc (512); if (lista == NULL) { - MU_POP3_CHECK_ERROR(pop3, ENOMEM); + /* MU_POP3_CHECK_ERROR(pop3, ENOMEM); + Do not use the macro we need to clear the list if errors. */ + pop3->io.ptr = pop3->io.buf; + pop3->state = MU_POP3_ERROR; + list_destroy (plist); + return ENOMEM; } + while ((status = mu_pop3_readline (pop3, lista, 512, &n)) == 0 && n > 0) { /* Nuke the trailing newline */ diff --git a/mailbox/pop/pop3_uidla.c b/mailbox/pop/pop3_uidla.c index 73ba56b97..38acd397f 100644 --- a/mailbox/pop/pop3_uidla.c +++ b/mailbox/pop/pop3_uidla.c @@ -64,12 +64,20 @@ mu_pop3_uidl_all (mu_pop3_t pop3, list_t *plist) But do not use the stack and malloc. */ char *uidla; size_t n = 0; - + uidla = malloc (512); if (uidla == NULL) { - MU_POP3_CHECK_ERROR(pop3, ENOMEM); + /* MU_POP3_CHECK_ERROR(pop3, ENOMEM) + Do not use the macro since we have to remove the list + if things go wrong. + */ + pop3->io.ptr = pop3->io.buf; + pop3->state = MU_POP3_ERROR; + list_destroy (plist); + return ENOMEM; } + while ((status = mu_pop3_readline (pop3, uidla, 512, &n)) == 0 && n > 0) { /* Nuke the trailing newline */ -- cgit v1.2.1