[Spice-devel] [spice-gtk v2 2/2] channel-usbredir: prevent crash when calling without host
Christophe Fergeau
cfergeau at redhat.com
Thu Dec 1 12:33:01 UTC 2016
On Wed, Nov 30, 2016 at 06:36:33PM +0100, Victor Toso wrote:
> From: Victor Toso <me at victortoso.com>
>
> Similar fix was done in 5b252b0f499601bcf387c02a4dd35d27ed34c
>
> We should log a critical message instead of crashing the application.
I think the log should be more detailed than in the previous iteration,
not less. It's much better to explain why this is a correct fix, and not
papering over another bug (priv->host being NULL when it really should
not). This could be just quoting some parts of
5b252b0f499601bcf387c02a4dd35d27ed34c if relevant, or describing a
scenario where the crash could occur on startup.
The way it is now, it looks more like "ok, NULL pointer here for
unknown reasons, let's avoid the crash"
Christophe
> Signed-off-by: Victor Toso <victortoso at redhat.com>
> ---
> src/channel-usbredir.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> 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 */
> usbredirhost_write_guest_data(priv->host);
> }
> --
> 2.9.3
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20161201/34da7902/attachment.sig>
More information about the Spice-devel
mailing list