Skip to content

Commit 90e9a44

Browse files
committed
shims: fix TAILQ_CONCAT() edge cases
This needs to set the `te_next` of the last element in `head1` and also handle the case where `head1` is empty. This fixes a hang in the dispatch_context_for_key test on Windows because the the queue-specific list was getting corrupted in `_dispatch_queue_specific_head_dispose()`.
1 parent c5af10f commit 90e9a44

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/shims/generic_sys_queue.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,11 @@
9494

9595
#define TAILQ_CONCAT(head1, head2, field) do { \
9696
if (!TAILQ_EMPTY(head2)) { \
97-
(head1)->tq_last = (head2)->tq_first; \
97+
if ((head1)->tq_last) { \
98+
(head1)->tq_last->field.te_next = (head2)->tq_first; \
99+
} else { \
100+
(head1)->tq_first = (head2)->tq_first; \
101+
} \
98102
(head2)->tq_first->field.te_prev = (head1)->tq_last; \
99103
(head1)->tq_last = (head2)->tq_last; \
100104
TAILQ_INIT((head2)); \

0 commit comments

Comments
 (0)