diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index aa8da5f179bb29c338900b6fb747db2f37f86326..79adbd09469c926d82a385c1fd3e70eb97dd0e26 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -14456,11 +14456,13 @@ AST_TEST_DEFINE(test_voicemail_notify_endl)
 		rewind(file);
 		while (fgets(buf, sizeof(buf), file)) {
 			if (
+			(strlen(buf) > 1 &&
 #ifdef IMAP_STORAGE
 			buf[strlen(buf) - 2] != '\r'
 #else
 			buf[strlen(buf) - 2] == '\r'
 #endif
+			)
 			|| buf[strlen(buf) - 1] != '\n') {
 				res = AST_TEST_FAIL;
 			}