Index: main/config_options.c =================================================================== --- main/config_options.c (revision 391701) +++ main/config_options.c (working copy) @@ -186,14 +186,14 @@ || xmldoc_update_config_option(types, info->module, opt->name, type->name, opt->default_val, opt->match_type == ACO_REGEX, opt->type) #endif /* AST_XML_DOCS */ ) { - while (--idx) { - ao2_unlink(types[idx]->internal->opts, opt); - } + do { + ao2_unlink(types[--idx]->internal->opts, opt); + } while (idx); return -1; } - /* The container should hold the only ref to opt */ - ao2_ref(opt, -1); } + /* The container should hold the only ref to opt */ + ao2_ref(opt, -1); return 0; }