diff --git a/main/pbx.c b/main/pbx.c
index 83bfb9036ccba9a891d95c08fbcb0321a988dd9a..8b869f162c0a5c42793da604c5e7135a168b62fa 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -2884,6 +2884,11 @@ static int pbx_extension_helper(struct ast_channel *c, struct ast_context *con,
 	int matching_action = (action == E_MATCH || action == E_CANMATCH || action == E_MATCHMORE);
 
 	ast_rdlock_contexts();
+
+	if (!context) {
+		context = con->name;
+	}
+
 	if (found)
 		*found = 0;