Merged revisions 193955 via svnmerge from
authorTilghman Lesher <tilghman@meg.abyt.es>
Tue, 12 May 2009 20:40:22 +0000 (20:40 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Tue, 12 May 2009 20:40:22 +0000 (20:40 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r193955 | tilghman | 2009-05-12 15:39:21 -0500 (Tue, 12 May 2009) | 6 lines

  Avoid initializing routines if the authentication fails.  Fixes a crash (RR) issue.
  (closes issue #14508)
   Reported by: tiziano
   Patches:
         20090221_2_wrongmailbox.diff.txt uploaded by tiziano (license 377)
........

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@193956 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_voicemail.c

index 0e77845..bcd0b48 100644 (file)
@@ -9069,6 +9069,10 @@ static int vm_execmain(struct ast_channel *chan, void *data)
        /* If ADSI is supported, setup login screen */
        adsi_begin(chan, &useadsi);
 
        /* If ADSI is supported, setup login screen */
        adsi_begin(chan, &useadsi);
 
+       if (!valid) {
+               goto out;
+       }
+
 #ifdef IMAP_STORAGE
        pthread_once(&ts_vmstate.once, ts_vmstate.key_init);
        pthread_setspecific(ts_vmstate.key, &vms);
 #ifdef IMAP_STORAGE
        pthread_once(&ts_vmstate.once, ts_vmstate.key_init);
        pthread_setspecific(ts_vmstate.key, &vms);
@@ -9080,9 +9084,6 @@ static int vm_execmain(struct ast_channel *chan, void *data)
        vmstate_insert(&vms);
        init_vm_state(&vms);
 #endif
        vmstate_insert(&vms);
        init_vm_state(&vms);
 #endif
-       if (!valid)
-               goto out;
-
        if (!(vms.deleted = ast_calloc(vmu->maxmsg, sizeof(int)))) {
                ast_log(AST_LOG_ERROR, "Could not allocate memory for deleted message storage!\n");
                cmd = ast_play_and_wait(chan, "an-error-has-occured");
        if (!(vms.deleted = ast_calloc(vmu->maxmsg, sizeof(int)))) {
                ast_log(AST_LOG_ERROR, "Could not allocate memory for deleted message storage!\n");
                cmd = ast_play_and_wait(chan, "an-error-has-occured");
@@ -9634,7 +9635,9 @@ out:
        }
        /*  before we delete the state, we should copy pertinent info
         *  back to the persistent model */
        }
        /*  before we delete the state, we should copy pertinent info
         *  back to the persistent model */
-       vmstate_delete(&vms);
+       if (vmu) {
+               vmstate_delete(&vms);
+       }
 #endif
        if (vmu)
                free_user(vmu);
 #endif
        if (vmu)
                free_user(vmu);