From 4067e5472795c1dd9152636116271b96819f5941 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Tue, 21 Jul 2009 01:06:36 +0300 Subject: [PATCH] lookup_unique_name: Handle NULL from msg_box If msg_box() runs out of memory, it returns NULL. In this case, the done_handler_T callbacks of the buttons will not be called. So lookup_unique_name() must instead free the struct lun_hop on its own. --- src/session/download.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/session/download.c b/src/session/download.c index 30908edc..0474ece4 100644 --- a/src/session/download.c +++ b/src/session/download.c @@ -666,8 +666,9 @@ lookup_unique_name(struct terminal *term, unsigned char *ofile, lun_callback_T *callback, void *data) { /* [gettext_accelerator_context(.lookup_unique_name)] */ - struct lun_hop *lun_hop; + struct lun_hop *lun_hop = NULL; unsigned char *file = NULL; + struct dialog_data *dialog_data; int overwrite; ofile = expand_tilde(ofile); @@ -721,7 +722,8 @@ lookup_unique_name(struct terminal *term, unsigned char *ofile, lun_hop->data = data; lun_hop->resume = resume; - msg_box(term, NULL, MSGBOX_FREE_TEXT, + dialog_data = msg_box( + term, NULL, MSGBOX_FREE_TEXT, N_("File exists"), ALIGN_CENTER, msg_text(term, N_("This file already exists:\n" "%s\n\n" @@ -737,9 +739,11 @@ lookup_unique_name(struct terminal *term, unsigned char *ofile, : NULL), lun_resume, 0), MSG_BOX_BUTTON(N_("~Cancel"), lun_cancel, B_ESC)); + if (!dialog_data) goto error; return; error: + mem_free_if(lun_hop); if (file != ofile) mem_free_if(file); mem_free_if(ofile); callback(term, NULL, data, resume & ~DOWNLOAD_RESUME_SELECTED);