Re: [spice-gtk 1/2] Fix empty clipboard check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ack

On Mon, Nov 17, 2014 at 3:17 PM, Christophe Fergeau <cfergeau@xxxxxxxxxx> wrote:
> SpiceGtkSession::clipboard_received_cb starts by checking if the
> length of the X selection data is not 0. However, right after this check,
> if gtk_selection_data_get_length() returned -1, it decides it got an
> empty clipboard, sets the selection length to 0, and does not return
> early.
> This commit reworks the len == 0 / len == -1 checks to make sure we
> always return early when we get no data from the clipboard.
> ---
>  gtk/spice-gtk-session.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/gtk/spice-gtk-session.c b/gtk/spice-gtk-session.c
> index 10bd762..26a0ecf 100644
> --- a/gtk/spice-gtk-session.c
> +++ b/gtk/spice-gtk-session.c
> @@ -852,12 +852,12 @@ static void clipboard_received_cb(GtkClipboard *clipboard,
>
>      g_object_get(s->main, "max-clipboard", &max_clipboard, NULL);
>      len = gtk_selection_data_get_length(selection_data);
> -    if (len == 0 || (max_clipboard != -1 && len > max_clipboard)) {
> +    if (max_clipboard != -1 && len > max_clipboard) {
>          g_warning("discarded clipboard of size %d (max: %d)", len, max_clipboard);
>          return;
> -    } else if (len == -1) {
> -        SPICE_DEBUG("empty clipboard");
> -        len = 0;
> +    } else if (len <= 0) {
> +        SPICE_DEBUG("discarding empty clipboard");
> +        return;
>      } else {
>          atom = gtk_selection_data_get_data_type(selection_data);
>          name = gdk_atom_name(atom);
> --
> 2.1.0
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@xxxxxxxxxxxxxxxxxxxxx
> http://lists.freedesktop.org/mailman/listinfo/spice-devel



-- 
Marc-André Lureau
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]