Index: chan_agent.c =================================================================== --- chan_agent.c (revision 42855) +++ chan_agent.c (working copy) @@ -739,9 +739,11 @@ * agent_request() is followed immediately by agent_hangup() * as in apps/app_chanisavail.c:chanavail_exec() */ + + if (p->u != NULL) { + ast_module_user_remove(p->u); + } - ast_module_user_remove(p->u); - if (option_debug) ast_log(LOG_DEBUG, "Hangup called for state %s\n", ast_state2str(ast->_state)); if (p->start && (ast->_state != AST_STATE_UP)) {