[asterisk-commits] twilson: trunk r350365 - /trunk/main/channel.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Jan 11 13:19:39 CST 2012
Author: twilson
Date: Wed Jan 11 13:19:35 2012
New Revision: 350365
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=350365
Log:
Always treat arguments to the get_by_name_cb strings
Initially, support was left in for the old style of searching, even
though it wasn't actually used. In the case of name_len != 0, the
OBJ_KEY flag isn't passed because we aren't matching on a full key
and therefor can't use the hash function to optimize. The code left
in to support the old way of searching unfortunately treated a prefix
search like this as though an ast_channel struct was passed as an arg
and caused a crash.
This patch also adds needed parentheses around some matching conditions.
(closes issue ASTERISK-19182)
Modified:
trunk/main/channel.c
Modified: trunk/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/channel.c?view=diff&rev=350365&r1=350364&r2=350365
==============================================================================
--- trunk/main/channel.c (original)
+++ trunk/main/channel.c Wed Jan 11 13:19:35 2012
@@ -1420,7 +1420,7 @@
static int ast_channel_by_name_cb(void *obj, void *arg, void *data, int flags)
{
struct ast_channel *chan = obj;
- const char *name = (flags & OBJ_KEY) ? arg : ast_channel_name((struct ast_channel *)arg);
+ const char *name = arg;
size_t name_len = *(size_t *)data;
int ret = CMP_MATCH;
@@ -1430,7 +1430,8 @@
}
ast_channel_lock(chan);
- if (!name_len && (strcasecmp(ast_channel_name(chan), name) || (name_len && strncasecmp(ast_channel_name(chan), name, name_len)))) {
+
+ if ((!name_len && strcasecmp(ast_channel_name(chan), name)) || (name_len && strncasecmp(ast_channel_name(chan), name, name_len))) {
ret = 0; /* name match failed, keep looking */
}
ast_channel_unlock(chan);
@@ -1473,8 +1474,8 @@
}
ast_channel_lock(chan);
- if (!name_len && (strcasecmp(chan->uniqueid, uniqueid) ||
- (name_len && strncasecmp(chan->uniqueid, uniqueid, name_len)))) {
+ if ((!name_len && strcasecmp(chan->uniqueid, uniqueid)) ||
+ (name_len && strncasecmp(chan->uniqueid, uniqueid, name_len))) {
ret = 0;
}
ast_channel_unlock(chan);
More information about the asterisk-commits
mailing list