From 16bc4ed93c855a9e2a61277a7a821d3a46f237e4 Mon Sep 17 00:00:00 2001 From: Alexei Gradinari Date: Wed, 14 Aug 2019 15:52:01 -0400 Subject: [PATCH] app_voicemail/IMAP: check mailstream not NULL in leave_voicemail The function leave_voicemail checks if expungeonhangup is set, but does not check if IMAP stream is closed, so it could call imap function with NULL stream. This leads to segfault. ASTERISK-28505 #close Change-Id: Ib66c57c1f1ba97774e447b36349198e2626a8d7c --- apps/app_voicemail.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 56ade7f876..a51c3c7f28 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -7212,7 +7212,7 @@ leave_vm_out: #ifdef IMAP_STORAGE /* expunge message - use UID Expunge if supported on IMAP server*/ ast_debug(3, "*** Checking if we can expunge, expungeonhangup set to %d\n", expungeonhangup); - if (expungeonhangup == 1) { + if (expungeonhangup == 1 && vms->mailstream != NULL) { ast_mutex_lock(&vms->lock); #ifdef HAVE_IMAP_TK2006 if (LEVELUIDPLUS (vms->mailstream)) { -- 2.47.2