[Spice-devel,spice-gtk,v3] channel-usbredir: prevent crash when calling without host

Submitted by Victor Toso on Dec. 1, 2016, 2:19 p.m.


Message ID 20161201141931.29241-1-victortoso@redhat.com
State New
Headers show
Series "Series without cover letter" ( rev: 2 ) in Spice

Not browsing as part of any series.

Commit Message

Victor Toso Dec. 1, 2016, 2:19 p.m.
From: Victor Toso <me@victortoso.com>

As spice_usbredir_channel_up() can be called when channel-usbredir is
not yet initialized, priv->host can be NULL leading to a crash in

See previous patch that does initialize SpiceUsbDeviceManager on
SpiceSession init and also the comment in 5b252b0f499601bcf387c02a4
which fix similar behavior.

We should simply log a critical message instead of crashing the

Signed-off-by: Victor Toso <victortoso@redhat.com>
 src/channel-usbredir.c | 2 ++
 1 file changed, 2 insertions(+)

Patch hide | download patch | download mbox

diff --git a/src/channel-usbredir.c b/src/channel-usbredir.c
index 4837d68..392a35e 100644
--- a/src/channel-usbredir.c
+++ b/src/channel-usbredir.c
@@ -817,6 +817,8 @@  static void spice_usbredir_channel_up(SpiceChannel *c)
     SpiceUsbredirChannel *channel = SPICE_USBREDIR_CHANNEL(c);
     SpiceUsbredirChannelPrivate *priv = channel->priv;
+    g_return_if_fail(priv->host != NULL);
     /* Flush any pending writes */