diff --git a/apps/app_groupcount.c b/apps/app_groupcount.c
index 094822f6d5057b872619f508c4a0cb4716aad51e..778a1399b729b5502abc8918bde61c4bf29920d7 100755
--- a/apps/app_groupcount.c
+++ b/apps/app_groupcount.c
@@ -68,7 +68,7 @@ static int group_get_count(char *group)
 		chan = ast_channel_walk(NULL);
 		while(chan) {
 			test = pbx_builtin_getvar_helper(chan, "GROUP");
-			if (!strcasecmp(test, group))
+			if (test && !strcasecmp(test, group))
 				count++;
 			chan = ast_channel_walk(chan);
 		}