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
This commit is contained in:
Sean Bright 2021-11-30 15:16:45 -05:00 committed by Friendly Automation
parent 04d00c203c
commit c37cc5d3bc
1 changed files with 5 additions and 5 deletions

View File

@ -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);
}