[Spice-devel] [spice-gtk 1/2] Fix empty clipboard check

Marc-André Lureau marcandre.lureau at gmail.com
Mon Nov 17 06:53:42 PST 2014


ack

On Mon, Nov 17, 2014 at 3:17 PM, Christophe Fergeau <cfergeau at redhat.com> 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 at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel



-- 
Marc-André Lureau


More information about the Spice-devel mailing list