diff --git a/apps/app_directory.c b/apps/app_directory.c
index e1f5fb27b30a0b272aa1651a007a27152959520d..34001ad514f88a58d0f8d2eff14f0a6a04810b68 100644
--- a/apps/app_directory.c
+++ b/apps/app_directory.c
@@ -525,6 +525,11 @@ static int search_directory_sub(const char *context, struct ast_config *vmcfg, s
 		strsep(&bufptr, ",");
 		pos = strsep(&bufptr, ",");
 
+		/* No name to compare against */
+		if (ast_strlen_zero(pos)) {
+			continue;
+		}
+
 		res = 0;
 		if (ast_test_flag(&flags, OPT_LISTBYLASTNAME)) {
 			res = check_match(&item, context, pos, v->name, ext, 0 /* use_first_name */);