Index: main/pbx.c =================================================================== --- main/pbx.c (revision 89398) +++ main/pbx.c (working copy) @@ -209,7 +209,7 @@ 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 */ 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 */ char name[0]; /*!< Name of the context */ @@ -3705,10 +3705,10 @@ * The next node is either the next priority or the next extension */ struct ast_exten *next_node = peer->peer ? peer->peer : peer->next; - if (next_node == peer->peer) { + if (next_node && next_node == peer->peer) { next_node->peer_tree = exten->peer_tree; /* move the priority hash tabs over */ exten->peer_tree = 0; - next_node->peer_tree = exten->peer_label_tree; + next_node->peer_label_tree = exten->peer_label_tree; exten->peer_label_tree = 0; } if (!prev_exten) { /* change the root... */ @@ -4798,7 +4798,7 @@ strcpy(tmp->name, name); tmp->root = NULL; tmp->root_tree = NULL; - tmp->registrar = registrar; + tmp->registrar = ast_strdup(registrar); tmp->includes = NULL; tmp->ignorepats = NULL; } @@ -6350,6 +6350,7 @@ destroy_exten(el); } ast_rwlock_destroy(&tmp->lock); + ast_free(tmp->registrar); ast_free(tmp); /* if we have a specific match, we are done, otherwise continue */ tmp = con ? NULL : next; Index: res/res_features.c =================================================================== --- res/res_features.c (revision 89398) +++ res/res_features.c (working copy) @@ -3297,6 +3297,7 @@ static int unload_module(void) { + struct ast_context *con; ast_manager_unregister("ParkedCalls"); ast_manager_unregister("Bridge"); ast_manager_unregister("Park"); @@ -3304,6 +3305,12 @@ ast_unregister_application(parkcall); ast_unregister_application(app_bridge); ast_devstate_prov_del("Park"); + con = ast_context_find(parking_con); + if (con) + ast_context_destroy(con, registrar); + con = ast_context_find(parking_con_dial); + if (con) + ast_context_destroy(con, registrar); return ast_unregister_application(parkedcall); }