From: Sean Bright Date: Tue, 30 Nov 2021 20:16:45 +0000 (-0500) Subject: channel: Short-circuit ast_channel_get_by_name() on empty arg. X-Git-Tag: 19.2.0-rc1~69 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4195949e0708efd944451dcdd19acfbac9120f99;p=thirdparty%2Fasterisk.git 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); }