Fix potential infinite loop
---
 server/stream.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/server/stream.c b/server/stream.c
index 934b236..49b5910 100644
--- a/server/stream.c
+++ b/server/stream.c
@@ -331,11 +331,10 @@ void detach_stream(DisplayChannel *display, Stream 
*stream)
 static void before_reattach_stream(DisplayChannel *display,
                                    Stream *stream, Drawable *new_frame)
 {
-    RedDrawablePipeItem *dpi;
     DisplayChannelClient *dcc;
     int index;
     StreamAgent *agent;
-    GList *dpi_item;
+    GList *dpi_link, *dpi_next;
     GList *link, *link_next;
 
     spice_return_if_fail(stream->current);
@@ -350,10 +349,9 @@ static void before_reattach_stream(DisplayChannel *display,
     }
 
     index = display_channel_get_stream_id(display, stream);
-    dpi_item = stream->current->pipes;
-    while (dpi_item) {
-        GList *dpi_next = dpi_item->next;
-        dpi = dpi_item->data;
+    for (dpi_link = stream->current->pipes; dpi_link; dpi_link = dpi_next) {
+        RedDrawablePipeItem *dpi = dpi_link->data;
+        dpi_next = dpi_link->next;
         dcc = dpi->dcc;
         agent = dcc_get_stream_agent(dcc, index);
 
@@ -373,7 +371,6 @@ static void before_reattach_stream(DisplayChannel *display,
                 ++agent->drops;
             }
         }
-        dpi_item = dpi_next;
     }
 
 
-- 
2.7.4

_______________________________________________
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel

Reply via email to