From: Arran Cudbard-Bell Date: Tue, 17 Nov 2020 19:31:28 +0000 (-0600) Subject: Fix crash on exit for certain virtual servers X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dbfed0b66098944c623da32a89101ed079ea0579;p=thirdparty%2Ffreeradius-server.git Fix crash on exit for certain virtual servers --- diff --git a/src/lib/server/virtual_servers.c b/src/lib/server/virtual_servers.c index d10e26331d3..5a107c70b0e 100644 --- a/src/lib/server/virtual_servers.c +++ b/src/lib/server/virtual_servers.c @@ -187,6 +187,7 @@ void virtual_server_dict_set(CONF_SECTION *server_cs, fr_dict_t const *dict, boo return; } + fr_dict_reference(fr_dict_unconst(dict)); p = talloc_zero(server_cs, virtual_server_dict_t); p->do_free = do_free; p->dict = dict; @@ -1244,7 +1245,7 @@ static int fr_app_process_instantiate(CONF_SECTION *server) int fr_app_process_type_parse(TALLOC_CTX *ctx, dl_module_inst_t **dl_module, CONF_ITEM *ci, fr_dict_attr_t const *packet_type, char const *proto_name, - char const **type_table, size_t type_table_len, + char const **type_table, size_t type_table_len, dl_module_inst_t **type_submodule_by_code, uint32_t code_max) { char const *type_str = cf_pair_value(cf_item_to_pair(ci)); diff --git a/src/lib/util/dict.h b/src/lib/util/dict.h index 4841ef59011..dca8ef56b48 100644 --- a/src/lib/util/dict.h +++ b/src/lib/util/dict.h @@ -488,6 +488,8 @@ int fr_dl_dict_attr_autoload(dl_t const *module, void *symbol, void *user_ctx) * * @{ */ +void fr_dict_reference(fr_dict_t *dict); + int fr_dict_free(fr_dict_t **dict); int fr_dict_const_free(fr_dict_t const **dict); diff --git a/src/lib/util/dict_util.c b/src/lib/util/dict_util.c index 68cd282db24..c1ba86f2aa0 100644 --- a/src/lib/util/dict_util.c +++ b/src/lib/util/dict_util.c @@ -2651,6 +2651,18 @@ fr_dict_t *dict_alloc(TALLOC_CTX *ctx) return dict; } +/** Manually increase the reference count for a dictionary + * + * This is useful if a previously loaded dictionary needs to + * be bound to the lifetime of an additional object. + * + * @param[in] dict to increase the reference count for. + */ +void fr_dict_reference(fr_dict_t *dict) +{ + talloc_increase_ref_count(dict); +} + /** Decrement the reference count on a previously loaded dictionary * * @param[in] dict to free.