[Spice-devel,spice-gtk,v1] clipboard: Fix crash by handling error

Submitted by Victor Toso on Oct. 14, 2016, 4:18 p.m.

Details

Message ID 20161014161834.17833-1-victortoso@redhat.com
State New
Headers show
Series "clipboard: Fix crash by handling error" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

Victor Toso Oct. 14, 2016, 4:18 p.m.
From: Victor Toso <me@victortoso.com>

As manual states below, text could be NULL for different reasons and
we should handle that. I've included a debug message to help
identifying possible regressions in wayland.

 "The text parameter to callback will contain the resulting text if
 the request succeeded, or NULL if it failed. This could happen for
 various reasons, in particular if the clipboard was empty or if the
 contents of the clipboard could not be converted into text form."

Resolves: rhbz#1384676

Signed-off-by: Victor Toso <victortoso@redhat.com>
---
 src/spice-gtk-session.c | 5 +++++
 1 file changed, 5 insertions(+)

Patch hide | download patch | download mbox

diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c
index 3ff4e9a..c08483c 100644
--- a/src/spice-gtk-session.c
+++ b/src/spice-gtk-session.c
@@ -945,6 +945,11 @@  static void clipboard_received_text_cb(GtkClipboard *clipboard,
     if (self == NULL)
         return;
 
+    if (text == NULL) {
+        SPICE_DEBUG ("Failed to retrieve clipboard text");
+        return;
+    }
+
     g_return_if_fail(SPICE_IS_GTK_SESSION(self));
 
     selection = get_selection_from_clipboard(self->priv, clipboard);

Comments

Hi

----- Original Message -----
> From: Victor Toso <me@victortoso.com>
> 
> As manual states below, text could be NULL for different reasons and
> we should handle that. I've included a debug message to help
> identifying possible regressions in wayland.
> 
>  "The text parameter to callback will contain the resulting text if
>  the request succeeded, or NULL if it failed. This could happen for
>  various reasons, in particular if the clipboard was empty or if the
>  contents of the clipboard could not be converted into text form."
> 
> Resolves: rhbz#1384676

If this is a regression from 7b0de6217670e0f668aff2949fba174ed3cc0b50, it's worth to point it out, and copy Christophe

> 
> Signed-off-by: Victor Toso <victortoso@redhat.com>
> ---
>  src/spice-gtk-session.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c
> index 3ff4e9a..c08483c 100644
> --- a/src/spice-gtk-session.c
> +++ b/src/spice-gtk-session.c
> @@ -945,6 +945,11 @@ static void clipboard_received_text_cb(GtkClipboard
> *clipboard,
>      if (self == NULL)
>          return;
>  
> +    if (text == NULL) {
> +        SPICE_DEBUG ("Failed to retrieve clipboard text");
> +        return;
> +    }
> +
>      g_return_if_fail(SPICE_IS_GTK_SESSION(self));
>  
>      selection = get_selection_from_clipboard(self->priv, clipboard);
> --
> 2.9.3
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
>
Hi,

On Fri, Oct 14, 2016 at 05:32:25PM -0400, Marc-André Lureau wrote:
> Hi
>
> ----- Original Message -----
> > From: Victor Toso <me@victortoso.com>
> >
> > As manual states below, text could be NULL for different reasons and
> > we should handle that. I've included a debug message to help
> > identifying possible regressions in wayland.
> >
> >  "The text parameter to callback will contain the resulting text if
> >  the request succeeded, or NULL if it failed. This could happen for
> >  various reasons, in particular if the clipboard was empty or if the
> >  contents of the clipboard could not be converted into text form."
> >
> > Resolves: rhbz#1384676
>
> If this is a regression from 7b0de6217670e0f668aff2949fba174ed3cc0b50,
> it's worth to point it out, and copy Christophe

Right. This function was introduced on 7b0de621 and so was this
bug. The crash is a regression but I'm not sure if before 7b0de621
clipboard text would exist anyway.

We'll need to backport this fix on rhel 7 to avoid regressions.
I'll open downstream bugs to avoid this crash.

  toso

> 
> > 
> > Signed-off-by: Victor Toso <victortoso@redhat.com>
> > ---
> >  src/spice-gtk-session.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> > 
> > diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c
> > index 3ff4e9a..c08483c 100644
> > --- a/src/spice-gtk-session.c
> > +++ b/src/spice-gtk-session.c
> > @@ -945,6 +945,11 @@ static void clipboard_received_text_cb(GtkClipboard
> > *clipboard,
> >      if (self == NULL)
> >          return;
> >  
> > +    if (text == NULL) {
> > +        SPICE_DEBUG ("Failed to retrieve clipboard text");
> > +        return;
> > +    }
> > +
> >      g_return_if_fail(SPICE_IS_GTK_SESSION(self));
> >  
> >      selection = get_selection_from_clipboard(self->priv, clipboard);
> > --
> > 2.9.3
> > 
> > _______________________________________________
> > Spice-devel mailing list
> > Spice-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/spice-devel
> >