diff --git a/main/pbx.c b/main/pbx.c
index 973a44b9c27d9e72d6a0e3fd30adae1056794bd1..275a6a7bf4907ab5dc4948d89467174f87e5f198 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -2614,7 +2614,7 @@ static int extension_match_core(const char *pattern, const char *data, enum ext_
 		prof_id = ast_add_profile("ext_match", 0);
 	}
 	ast_mark(prof_id, 1);
-	i = _extension_match_core(pattern, data, mode);
+	i = _extension_match_core(ast_strlen_zero(pattern) ? "" : pattern, ast_strlen_zero(data) ? "" : data, mode);
 	ast_mark(prof_id, 0);
 	return i;
 }