mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
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.
This commit is contained in:
parent
b80c0e8a0d
commit
4067e54727
@ -666,8 +666,9 @@ lookup_unique_name(struct terminal *term, unsigned char *ofile,
|
|||||||
lun_callback_T *callback, void *data)
|
lun_callback_T *callback, void *data)
|
||||||
{
|
{
|
||||||
/* [gettext_accelerator_context(.lookup_unique_name)] */
|
/* [gettext_accelerator_context(.lookup_unique_name)] */
|
||||||
struct lun_hop *lun_hop;
|
struct lun_hop *lun_hop = NULL;
|
||||||
unsigned char *file = NULL;
|
unsigned char *file = NULL;
|
||||||
|
struct dialog_data *dialog_data;
|
||||||
int overwrite;
|
int overwrite;
|
||||||
|
|
||||||
ofile = expand_tilde(ofile);
|
ofile = expand_tilde(ofile);
|
||||||
@ -721,7 +722,8 @@ lookup_unique_name(struct terminal *term, unsigned char *ofile,
|
|||||||
lun_hop->data = data;
|
lun_hop->data = data;
|
||||||
lun_hop->resume = resume;
|
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,
|
N_("File exists"), ALIGN_CENTER,
|
||||||
msg_text(term, N_("This file already exists:\n"
|
msg_text(term, N_("This file already exists:\n"
|
||||||
"%s\n\n"
|
"%s\n\n"
|
||||||
@ -737,9 +739,11 @@ lookup_unique_name(struct terminal *term, unsigned char *ofile,
|
|||||||
: NULL),
|
: NULL),
|
||||||
lun_resume, 0),
|
lun_resume, 0),
|
||||||
MSG_BOX_BUTTON(N_("~Cancel"), lun_cancel, B_ESC));
|
MSG_BOX_BUTTON(N_("~Cancel"), lun_cancel, B_ESC));
|
||||||
|
if (!dialog_data) goto error;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
mem_free_if(lun_hop);
|
||||||
if (file != ofile) mem_free_if(file);
|
if (file != ofile) mem_free_if(file);
|
||||||
mem_free_if(ofile);
|
mem_free_if(ofile);
|
||||||
callback(term, NULL, data, resume & ~DOWNLOAD_RESUME_SELECTED);
|
callback(term, NULL, data, resume & ~DOWNLOAD_RESUME_SELECTED);
|
||||||
|
Loading…
Reference in New Issue
Block a user