From 42942b790d919f2cb8a27328def075de1ed732e9 Mon Sep 17 00:00:00 2001 From: Steve Murphy Date: Fri, 11 Jul 2008 22:03:19 +0000 Subject: [PATCH] (closes issue #13041) Reported by: eliel OK, now the context registrar slot is strdup'd. It is freed on destruction. I don't see the need to do this with all the structs' registrar fields, but if some wild case proves they should also be handled this way, then we can put in the extra work at that time. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@130297 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- main/pbx.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/main/pbx.c b/main/pbx.c index f6fd561376..416312e9a6 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -213,7 +213,7 @@ struct ast_context { struct ast_context *next; /*!< Link them together */ struct ast_include *includes; /*!< Include other contexts */ struct ast_ignorepat *ignorepats; /*!< Patterns for which to continue playing dialtone */ - const char *registrar; /*!< Registrar */ + char *registrar; /*!< Registrar -- make sure you malloc this, as the registrar may have to survive module unloads */ int refcount; /*!< each module that would have created this context should inc/dec this as appropriate */ AST_LIST_HEAD_NOLOCK(, ast_sw) alts; /*!< Alternative switches */ ast_mutex_t macrolock; /*!< A lock to implement "exclusive" macros - held whilst a call is executing in the macro */ @@ -5617,7 +5617,7 @@ struct ast_context *ast_context_find_or_create(struct ast_context **extcontexts, strcpy(tmp->name, name); tmp->root = NULL; tmp->root_table = NULL; - tmp->registrar = registrar; + tmp->registrar = ast_strdup(registrar); tmp->includes = NULL; tmp->ignorepats = NULL; tmp->refcount = 1; @@ -7305,6 +7305,9 @@ static void __ast_internal_context_destroy( struct ast_context *con) ipi = ipi->next; ast_free(ipl); } + if (tmp->registrar) + ast_free(tmp->registrar); + /* destroy the hash tabs */ if (tmp->root_table) { ast_hashtab_destroy(tmp->root_table, 0);