diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 7d632c82f5..f762cc9932 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -9302,7 +9302,7 @@ out: #ifdef IMAP_STORAGE /* expunge message - use UID Expunge if supported on IMAP server*/ 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) { + if (vmu && deleted == 1 && expungeonhangup == 1 && vms.mailstream != NULL) { #ifdef HAVE_IMAP_TK2006 if (LEVELUIDPLUS (vms.mailstream)) { mail_expunge_full(vms.mailstream,NIL,EX_UID);