From c5b6526ae29ea82e87db489611a0e87ea98082e4 Mon Sep 17 00:00:00 2001
From: Ivica Ico Bukvic <ico@vt.edu>
Date: Wed, 10 Dec 2014 18:49:01 -0500
Subject: [PATCH] *added bugfix provided by Miller Puckette

---
 pd/src/s_inter.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/pd/src/s_inter.c b/pd/src/s_inter.c
index 75a8ffeb1..78f115ee8 100644
--- a/pd/src/s_inter.c
+++ b/pd/src/s_inter.c
@@ -879,12 +879,13 @@ void sys_unqueuegui(void *client)
     t_guiqueue *gq, *gq2;
     if (!sys_guiqueuehead)
         return;
-    if (sys_guiqueuehead->gq_client == client)
+    while (sys_guiqueuehead->gq_client == client)
     {
-        t_freebytes(sys_guiqueuehead, sizeof(*sys_guiqueuehead));
-        sys_guiqueuehead = 0;
+        gq = sys_guiqueuehead;
+        sys_guiqueuehead = sys_guiqueuehead->gq_next;
+        t_freebytes(gq, sizeof(*gq));
     }
-    else for (gq = sys_guiqueuehead; gq2 = gq->gq_next; gq = gq2)
+    for (gq = sys_guiqueuehead; gq2 = gq->gq_next; gq = gq2)
         if (gq2->gq_client == client)
     {
         gq->gq_next = gq2->gq_next;
-- 
GitLab