mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
config/options: arrange add_opt() to use only mem_free() instead of
delete_option() in case of allocation failure.
This commit is contained in:
parent
c3cf5b9474
commit
6637272c5a
@ -465,28 +465,19 @@ add_opt(struct option *tree, unsigned char *path, unsigned char *capt,
|
|||||||
|
|
||||||
debug_check_option_syntax(option);
|
debug_check_option_syntax(option);
|
||||||
|
|
||||||
if (option->type != OPT_ALIAS
|
|
||||||
&& ((tree->flags & OPT_LISTBOX) || (option->flags & OPT_LISTBOX))) {
|
|
||||||
option->box_item = init_option_listbox_item(option);
|
|
||||||
if (!option->box_item) {
|
|
||||||
delete_option(option);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* XXX: For allocated values we allocate in the add_opt_<type>() macro.
|
/* XXX: For allocated values we allocate in the add_opt_<type>() macro.
|
||||||
* This involves OPT_TREE and OPT_STRING. */
|
* This involves OPT_TREE and OPT_STRING. */
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case OPT_TREE:
|
case OPT_TREE:
|
||||||
if (!value) {
|
if (!value) {
|
||||||
delete_option(option);
|
mem_free(option);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
option->value.tree = value;
|
option->value.tree = value;
|
||||||
break;
|
break;
|
||||||
case OPT_STRING:
|
case OPT_STRING:
|
||||||
if (!value) {
|
if (!value) {
|
||||||
delete_option(option);
|
mem_free(option);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
option->value.string = value;
|
option->value.string = value;
|
||||||
@ -511,6 +502,15 @@ add_opt(struct option *tree, unsigned char *path, unsigned char *capt,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (option->type != OPT_ALIAS
|
||||||
|
&& ((tree->flags & OPT_LISTBOX) || (option->flags & OPT_LISTBOX))) {
|
||||||
|
option->box_item = init_option_listbox_item(option);
|
||||||
|
if (!option->box_item) {
|
||||||
|
mem_free(option);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
add_opt_rec(tree, path, option);
|
add_opt_rec(tree, path, option);
|
||||||
return option;
|
return option;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user