]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Fix crash on exit for certain virtual servers
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 17 Nov 2020 19:31:28 +0000 (13:31 -0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 17 Nov 2020 19:31:37 +0000 (13:31 -0600)
src/lib/server/virtual_servers.c
src/lib/util/dict.h
src/lib/util/dict_util.c

index d10e26331d31eeeb10b91df5f0cb6169d4a9212d..5a107c70b0ed47e30b39c6f60cff18ffcd30e024 100644 (file)
@@ -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));
index 4841ef590110a0d29630125ee0aeba77186add0f..dca8ef56b480cd370ccd0398a7f2b5713250e2d6 100644 (file)
@@ -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);
index 68cd282db240414afe024991dc11901e4ff3aabe..c1ba86f2aa0716be77394c3b4851984a4f6e549e 100644 (file)
@@ -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.