aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--channel.c6
1 files changed, 5 insertions, 1 deletions
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)) ||