Index: apps/app_voicemail.c =================================================================== --- apps/app_voicemail.c (revision 153904) +++ apps/app_voicemail.c (working copy) @@ -9304,11 +9304,13 @@ ast_debug(3, "*** Checking if we can expunge, deleted set to %d, expungeonhangup set to %d\n",deleted,expungeonhangup); if (vmu && deleted == 1 && expungeonhangup == 1) { #ifdef HAVE_IMAP_TK2006 - if (LEVELUIDPLUS (vms.mailstream)) { + if (vms.mailstream != NULL && LEVELUIDPLUS (vms.mailstream)) { mail_expunge_full(vms.mailstream,NIL,EX_UID); } else #endif - mail_expunge(vms.mailstream); + if (vms.mailstream != NULL) { + mail_expunge(vms.mailstream); + } } /* before we delete the state, we should copy pertinent info * back to the persistent model */