From 6b6473d02c5d9448fa375ca06aa8598d8d04cab0 Mon Sep 17 00:00:00 2001 From: Laurent MONIN Date: Mon, 26 Jun 2006 17:33:00 +0200 Subject: [PATCH] config/options: arrange add_opt() to use only mem_free() instead of delete_option() in case of allocation failure. (cherry picked from commit 6637272c5abb33b474b6ac48e7a5080adc4210a4) --- src/config/options.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/config/options.c b/src/config/options.c index e542b8e1..5cecca0d 100644 --- a/src/config/options.c +++ b/src/config/options.c @@ -493,28 +493,19 @@ add_opt(struct option *tree, unsigned char *path, unsigned char *capt, 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_() macro. * This involves OPT_TREE and OPT_STRING. */ switch (type) { case OPT_TREE: if (!value) { - delete_option(option); + mem_free(option); return NULL; } option->value.tree = value; break; case OPT_STRING: if (!value) { - delete_option(option); + mem_free(option); return NULL; } option->value.string = value; @@ -539,6 +530,15 @@ add_opt(struct option *tree, unsigned char *path, unsigned char *capt, 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); return option; }