mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-14 00:24:05 +00:00
manager_channels.c: Fix allocation failure crash.
An earlier allocation failure failed to create a channel snapshot for the AMI HangupRequest/SoftHangupRequest event which resulted in a crash in channel_hangup_request_cb(). Where the stasis message gets generated cannot tell if the NULL snapshot returned was because of an allocation failure or the channel was a dummy channel. * Made channel_hangup_request_cb() check if the channel blob has a snapshot and exit if it doesn't. * Eliminated the RAII_VAR usage in channel_hangup_request_cb(). Change-Id: I0b6a1c4e95cbb7d80b2a7054c6eadecc169dfd24
This commit is contained in:
@@ -697,20 +697,25 @@ static void channel_hangup_request_cb(void *data,
|
|||||||
struct stasis_message *message)
|
struct stasis_message *message)
|
||||||
{
|
{
|
||||||
struct ast_channel_blob *obj = stasis_message_data(message);
|
struct ast_channel_blob *obj = stasis_message_data(message);
|
||||||
RAII_VAR(struct ast_str *, extra, NULL, ast_free);
|
struct ast_str *extra;
|
||||||
RAII_VAR(struct ast_str *, channel_event_string, NULL, ast_free);
|
struct ast_str *channel_event_string;
|
||||||
struct ast_json *cause;
|
struct ast_json *cause;
|
||||||
int is_soft;
|
int is_soft;
|
||||||
char *manager_event = "HangupRequest";
|
char *manager_event = "HangupRequest";
|
||||||
|
|
||||||
|
if (!obj->snapshot) {
|
||||||
|
/* No snapshot? Likely an earlier allocation failure creating it. */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
extra = ast_str_create(20);
|
extra = ast_str_create(20);
|
||||||
if (!extra) {
|
if (!extra) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
channel_event_string = ast_manager_build_channel_state_string(obj->snapshot);
|
channel_event_string = ast_manager_build_channel_state_string(obj->snapshot);
|
||||||
|
|
||||||
if (!channel_event_string) {
|
if (!channel_event_string) {
|
||||||
|
ast_free(extra);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -730,6 +735,9 @@ static void channel_hangup_request_cb(void *data,
|
|||||||
"%s%s",
|
"%s%s",
|
||||||
ast_str_buffer(channel_event_string),
|
ast_str_buffer(channel_event_string),
|
||||||
ast_str_buffer(extra));
|
ast_str_buffer(extra));
|
||||||
|
|
||||||
|
ast_free(channel_event_string);
|
||||||
|
ast_free(extra);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void channel_chanspy_stop_cb(void *data, struct stasis_subscription *sub,
|
static void channel_chanspy_stop_cb(void *data, struct stasis_subscription *sub,
|
||||||
|
Reference in New Issue
Block a user