summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2009-06-12 16:42:34 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2009-06-12 16:53:21 +0100
commit30e212a22b35bd177360e5e34d9ffec3e1fdab54 (patch)
tree00fe8e8fedc63d1405d27d7d156478375a55ebf2
parent0649d9ffd4bc9f0d03701623d7e85489f83eb3a2 (diff)
fd.o #22182: fix a potential use-after-free in the callable example CM
In some environments (I'm not sure why my laptop isn't among them), closing the stream causes the channel to remove the last ref to the stream, resulting in a use-after-free and a possible segfault. This could be avoided by holding another ref for the duration of example_callable_media_stream_close, but Sjoerd and I agreed that this simpler fix (re-ordering to put the possible free last) was more appropriate. Reviewed-by: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
-rw-r--r--examples/cm/callable/media-stream.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/examples/cm/callable/media-stream.c b/examples/cm/callable/media-stream.c
index 1177064f2..3290029d1 100644
--- a/examples/cm/callable/media-stream.c
+++ b/examples/cm/callable/media-stream.c
@@ -389,12 +389,14 @@ example_callable_media_stream_close (ExampleCallableMediaStream *self)
g_message ("Sending to server: Closing stream %u",
self->priv->id);
- g_signal_emit (self, signals[SIGNAL_REMOVED], 0);
-
if (self->priv->connected_event_id != 0)
{
g_source_remove (self->priv->connected_event_id);
}
+
+ /* this has to come last, because the MediaChannel may unref us in
+ * response to the removed signal */
+ g_signal_emit (self, signals[SIGNAL_REMOVED], 0);
}
}