<div dir="ltr">ack<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, May 8, 2013 at 4:06 PM, Yonit Halperin <span dir="ltr"><<a href="mailto:yhalperi@redhat.com" target="_blank">yhalperi@redhat.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">---<br>
 server/red_channel.c | 10 ++++++++--<br>
 1 file changed, 8 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/server/red_channel.c b/server/red_channel.c<br>
index 9d71543..7fde50d 100644<br>
--- a/server/red_channel.c<br>
+++ b/server/red_channel.c<br>
@@ -1680,6 +1680,7 @@ static void red_channel_client_disconnect_dummy(RedChannelClient *rcc)<br>
<br>
 void red_channel_client_disconnect(RedChannelClient *rcc)<br>
 {<br>
+    RedsStream *stream;<br>
     spice_printerr("%p (channel %p type %d id %d)", rcc, rcc->channel,<br>
                                                 rcc->channel->type, rcc->channel->id);<br>
     if (rcc->dummy) {<br>
@@ -1694,14 +1695,19 @@ void red_channel_client_disconnect(RedChannelClient *rcc)<br>
         rcc->channel->core->watch_remove(rcc->stream->watch);<br>
         rcc->stream->watch = NULL;<br>
     }<br>
-    reds_stream_free(rcc->stream);<br>
-    rcc->stream = NULL;<br>
     if (rcc->latency_monitor.timer) {<br>
         rcc->channel->core->timer_remove(rcc->latency_monitor.timer);<br>
         rcc->latency_monitor.timer = NULL;<br>
     }<br>
     red_channel_remove_client(rcc);<br>
     rcc->channel->channel_cbs.on_disconnect(rcc);<br>
+    stream = rcc->stream;<br>
+    rcc->stream = NULL;<br>
+    /* reds_stream_free can lead to the whole client disconnection<br>
+     * (see reds_handle_channel_event).<br>
+     * We set stream = NULL before closing the stream, to avoid<br>
+     * double release, if red_channel_client_disconnect is called again */<br>
+    reds_stream_free(stream);<br>
 }<br>
<br>
 void red_channel_disconnect(RedChannel *channel)<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.8.1.4<br>
<br>
_______________________________________________<br>
Spice-devel mailing list<br>
<a href="mailto:Spice-devel@lists.freedesktop.org">Spice-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/spice-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/spice-devel</a><br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br>Marc-André Lureau
</div>