Merge "Prevent potential crash on blond transfer."

This commit is contained in:
Matt Jordan
2015-05-01 06:55:23 -05:00
committed by Gerrit Code Review

View File

@@ -1326,6 +1326,7 @@ static void dial_target_free(struct dial_target *doomed)
return; return;
} }
ast_free(doomed->dialstring); ast_free(doomed->dialstring);
ast_channel_cleanup(doomed->peer);
ast_free(doomed); ast_free(doomed);
} }
@@ -1348,7 +1349,7 @@ static void dial_masquerade_datastore_cleanup(struct dial_masquerade_datastore *
while ((cur = AST_LIST_REMOVE_HEAD(&masq_data->dialed_peers, list))) { while ((cur = AST_LIST_REMOVE_HEAD(&masq_data->dialed_peers, list))) {
dial_target_free(cur); dial_target_free(cur);
} }
masq_data->caller = NULL; masq_data->caller = ast_channel_cleanup(masq_data->caller);
} }
static void dial_masquerade_datastore_remove_chan(struct dial_masquerade_datastore *masq_data, struct ast_channel *chan) static void dial_masquerade_datastore_remove_chan(struct dial_masquerade_datastore *masq_data, struct ast_channel *chan)
@@ -1556,7 +1557,7 @@ static struct dial_masquerade_datastore *dial_masquerade_datastore_add(
ast_datastore_free(datastore); ast_datastore_free(datastore);
return NULL; return NULL;
} }
masq_data->caller = chan; masq_data->caller = ast_channel_ref(chan);
} }
datastore->data = masq_data; datastore->data = masq_data;
@@ -1604,7 +1605,7 @@ static int set_dial_masquerade(struct ast_channel *caller, struct ast_channel *p
return -1; return -1;
} }
} }
target->peer = peer; target->peer = ast_channel_ref(peer);
/* Put peer target into datastore */ /* Put peer target into datastore */
ao2_lock(masq_data); ao2_lock(masq_data);