aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2008-05-08 15:24:54 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2008-05-08 15:24:54 +0000
commit9b18860043dbbcae23cbedeac5c5f2c1de461e46 (patch)
tree9498c266baf7c19c51388332de38bfc4ef8ecf77
parent8141e83d1dd2c61b36565a432501e75af09574a8 (diff)
Don't use a channel before checking for channel allocation failure.
(closes issue #12609) Reported by: edantie git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@115551 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--main/pbx.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/main/pbx.c b/main/pbx.c
index d6564db4f..a4d9202ad 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -4609,13 +4609,13 @@ int ast_async_goto(struct ast_channel *chan, const char *context, const char *ex
the PBX, we have to make a new channel, masquerade, and start the PBX
at the new location */
struct ast_channel *tmpchan = ast_channel_alloc(0, chan->_state, 0, 0, chan->accountcode, chan->exten, chan->context, chan->amaflags, "AsyncGoto/%s", chan->name);
- if (chan->cdr) {
- ast_cdr_discard(tmpchan->cdr);
- tmpchan->cdr = ast_cdr_dup(chan->cdr); /* share the love */
- }
- if (!tmpchan)
+ if (!tmpchan) {
res = -1;
- else {
+ } else {
+ if (chan->cdr) {
+ ast_cdr_discard(tmpchan->cdr);
+ tmpchan->cdr = ast_cdr_dup(chan->cdr); /* share the love */
+ }
/* Make formats okay */
tmpchan->readformat = chan->readformat;
tmpchan->writeformat = chan->writeformat;