From: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx> This fixes queue_foreach crashing if callback calls queue_remove_all. --- src/shared/queue.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/shared/queue.c b/src/shared/queue.c index c9c0812..b589055 100644 --- a/src/shared/queue.c +++ b/src/shared/queue.c @@ -187,6 +187,11 @@ void *queue_peek_tail(struct queue *queue) return queue->tail->data; } +static bool direct_match(const void *a, const void *b) +{ + return a == b; +} + void queue_foreach(struct queue *queue, queue_foreach_func_t function, void *user_data) { @@ -206,6 +211,9 @@ void queue_foreach(struct queue *queue, queue_foreach_func_t function, entry = tmp->next; function(tmp->data, user_data); + + if (!queue_find(queue, direct_match, entry)) + break; } queue_unref(queue); } -- 1.9.0 -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html