Skip to content

[bug]: Fix: Use ast instead of p->chan to get the DIALSTATUS variable #1590

@Tinet-mucw

Description

@Tinet-mucw

Severity

Trivial

Versions

23.0.0

Components/Modules

main

Operating Environment

ubuntu 24.04

Frequency of Occurrence

None

Issue Description

After p->chan = NULL, ast still points to the valid channel object
Using ast safely accesses the channel's DIALSTATUS variable before it's fully destroyed

[root@bogon asterisk]# git diff
diff --git a/asterisk/asterisk-22.0.0/main/core_unreal.c b/asterisk/asterisk-22.0.0/main/core_unreal.c
index 2f3fc73f2..885cc9e26 100644
--- a/asterisk/main/core_unreal.c
+++ b/asterisk/main/core_unreal.c
@@ -1045,7 +1045,7 @@ int ast_unreal_hangup(struct ast_unreal_pvt *p, struct ast_channel *ast)
                ast_clear_flag(p, AST_UNREAL_CARETAKER_THREAD);
                p->chan = NULL;
                if (p->owner) {
-                       const char *status = pbx_builtin_getvar_helper(p->chan, "DIALSTATUS");
+                       const char *status = pbx_builtin_getvar_helper(ast, "DIALSTATUS");
 
                        if (status) {
                                ast_channel_hangupcause_set(p->owner, cause);

Relevant log output

Asterisk Issue Guidelines

  • Yes, I have read the Asterisk Issue Guidelines

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions