diff options
author | mmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-06-12 23:58:01 +0000 |
---|---|---|
committer | mmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-06-12 23:58:01 +0000 |
commit | 2bc990d3ae07fb497f1e9a47c37b8013888f8c58 (patch) | |
tree | a9f871dca8e7b71a4749c38e7d2dc9c28c662bd5 /apps/app_queue.c | |
parent | 348634804fff90929b6c8037ebb50f8e83ede8c9 (diff) |
Fix a segfault by not trying to store a stack address for
long-term use. Instead use the heap. I can't believe this
never happened *once* in my developer branch when I was testing.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@122461 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_queue.c')
-rw-r--r-- | apps/app_queue.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/apps/app_queue.c b/apps/app_queue.c index 6d893f56d..5e7289ae0 100644 --- a/apps/app_queue.c +++ b/apps/app_queue.c @@ -3050,11 +3050,18 @@ struct queue_transfer_ds { int starttime; }; +static void queue_transfer_destroy(void *data) +{ + struct queue_transfer_ds *qtds = data; + ast_free(qtds); +} + /*! \brief a datastore used to help correctly log attended transfers of queue callers */ static const struct ast_datastore_info queue_transfer_info = { .type = "queue_transfer", .chan_fixup = queue_transfer_fixup, + .destroy = queue_transfer_destroy, }; /*! \brief Log an attended transfer when a queue caller channel is masqueraded @@ -3102,7 +3109,12 @@ static int attended_transfer_occurred(struct ast_channel *chan) static void setup_transfer_datastore(struct queue_ent *qe, struct member *member, int starttime) { struct ast_datastore *ds; - struct queue_transfer_ds qtds; + struct queue_transfer_ds *qtds = ast_calloc(1, sizeof(qtds)); + + if (!qtds) { + ast_log(LOG_WARNING, "Memory allocation error!\n"); + return; + } ast_channel_lock(qe->chan); if (!(ds = ast_channel_datastore_alloc(&queue_transfer_info, NULL))) { @@ -3111,11 +3123,11 @@ static void setup_transfer_datastore(struct queue_ent *qe, struct member *member return; } - qtds.qe = qe; + qtds->qe = qe; /* This member is refcounted in try_calling, so no need to add it here, too */ - qtds.member = member; - qtds.starttime = starttime; - ds->data = &qtds; + qtds->member = member; + qtds->starttime = starttime; + ds->data = qtds; ast_channel_datastore_add(qe->chan, ds); ast_channel_unlock(qe->chan); } |