diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index a306f9d60ee0cac2006de9b07d5c93ec85f6e32b..66094b2bd72e6fffe1f5e9bd3ec0a74af886ea9d 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -2014,7 +2014,7 @@ static const char *mbox(int id) #ifdef USE_ODBC_STORAGE static int messagecount(const char *mailbox, int *newmsgs, int *oldmsgs) { - int x = 0; + int x = -1; int res; SQLHSTMT stmt; char sql[256]; @@ -2027,6 +2027,7 @@ static int messagecount(const char *mailbox, int *newmsgs, int *oldmsgs) *newmsgs = 0; if (oldmsgs) *oldmsgs = 0; + /* If no mailbox, return immediately */ if (ast_strlen_zero(mailbox)) return 0; @@ -2118,7 +2119,7 @@ static int messagecount(const char *mailbox, int *newmsgs, int *oldmsgs) SQLFreeHandle (SQL_HANDLE_STMT, stmt); odbc_release_obj(obj); *oldmsgs = atoi(rowdata); - x = 1; + x = 0; } else ast_log(LOG_WARNING, "Failed to obtain database object for '%s'!\n", odbc_database);