diff --git a/funcs/func_audiohookinherit.c b/funcs/func_audiohookinherit.c
index 74f89b9a3e28d291faa267a73ad69f237d64a36e..528aed51fb9e56a1d55dab9294b284db4922c35d 100644
--- a/funcs/func_audiohookinherit.c
+++ b/funcs/func_audiohookinherit.c
@@ -126,7 +126,6 @@ static void audiohook_inheritance_fixup(void *data, struct ast_channel *old_chan
 		ast_debug(3, "Moved audiohook %s from %s(%p) to %s(%p)\n",
 			audiohook->source, old_chan->name, old_chan, new_chan->name, new_chan);
 	}
-	ast_free(datastore);
 	return;
 }
 
@@ -143,6 +142,8 @@ static void audiohook_inheritance_destroy(void *data)
 	while ((inheritable_audiohook = AST_LIST_REMOVE_HEAD(&audiohook_inheritance_datastore->allowed_list, list))) {
 		ast_free(inheritable_audiohook);
 	}
+
+	ast_free(audiohook_inheritance_datastore);
 }
 
 /*! \brief create an audiohook_inheritance_datastore and attach it to a channel