From b40f9ac39fb2e5c5519a3d348c6405d312a37a34 Mon Sep 17 00:00:00 2001 From: tilghman Date: Sun, 25 Feb 2007 14:38:03 +0000 Subject: Issue 9130 - If prev is the last item on the channel list, then evaluating additional conditions (e.g. name prefix) will cause a NULL dereference. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.2@56684 f38db490-d61c-443f-a65b-d21fe96a405b --- channel.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'channel.c') diff --git a/channel.c b/channel.c index 82758b3d4..c218c437e 100644 --- a/channel.c +++ b/channel.c @@ -747,7 +747,11 @@ static struct ast_channel *channel_find_locked(const struct ast_channel *prev, if (c != prev) /* not this one */ continue; /* found, prepare to return c->next */ - c = c->next; + if ((c = c->next) == NULL) break; + /* If prev was the last item on the channel list, then we just + * want to return NULL, instead of trying to deref NULL in the + * next section. + */ } if (name) { /* want match by name */ if ((!namelen && strcasecmp(c->name, name)) || -- cgit v1.2.3