Commit e9cac5f4bf for asterisk.org

commit e9cac5f4bf6883ecd8741f40a00fbf3069a581a3
Author: Sean Bright <sean.bright@gmail.com>
Date:   Tue Nov 30 15:16:45 2021 -0500

    channel: Short-circuit ast_channel_get_by_name() on empty arg.

    We know that passing a NULL or empty argument to
    ast_channel_get_by_name() will never result in a matching channel and
    will always result in an error being emitted, so just short-circuit
    out in that case.

    ASTERISK-28219 #close

    Change-Id: I88eadc748e9c6996fc17467b0a05881bbfd00bce

diff --git a/main/channel.c b/main/channel.c
index 546f4f84e6..36afb7fe1b 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -1426,17 +1426,17 @@ struct ast_channel *ast_channel_get_by_name_prefix(const char *name, size_t name
 	struct ast_channel *chan;
 	char *l_name = (char *) name;

+	if (ast_strlen_zero(l_name)) {
+		/* We didn't have a name to search for so quit. */
+		return NULL;
+	}
+
 	chan = ast_channel_callback(ast_channel_by_name_cb, l_name, &name_len,
 		(name_len == 0) /* optimize if it is a complete name match */ ? OBJ_KEY : 0);
 	if (chan) {
 		return chan;
 	}

-	if (ast_strlen_zero(l_name)) {
-		/* We didn't have a name to search for so quit. */
-		return NULL;
-	}
-
 	/* Now try a search for uniqueid. */
 	return ast_channel_callback(ast_channel_by_uniqueid_cb, l_name, &name_len, 0);
 }