[spice-gtk v2] clipboard: Return early on fixup_clipboard_text errors()

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

 



5c8f400 "clipboard: Add clipboard_atom_to_vdagent_type helper"
mistakenly removed some early returns when text conversion fails for
some reason. This commit readds it.
---
Maybe this... Not really convinced. An alternative would be to g_strdup(text)
when we don't convert, but that's a fairly useless string duplication.

Christophe

 src/spice-gtk-session.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c
index 5766bbd..d29bf92 100644
--- a/src/spice-gtk-session.c
+++ b/src/spice-gtk-session.c
@@ -967,7 +967,6 @@ static char *fixup_clipboard_text(SpiceGtkSession *self, const char *text, int *
     char *conv = NULL;
     int new_len = *len;
 
-
     if (spice_main_agent_test_capability(self->priv->main, VD_AGENT_CAP_GUEST_LINEEND_CRLF)) {
         GError *err = NULL;
 
@@ -975,6 +974,7 @@ static char *fixup_clipboard_text(SpiceGtkSession *self, const char *text, int *
         if (err) {
             g_warning("Failed to convert text line ending: %s", err->message);
             g_clear_error(&err);
+            *len = -1;
             return NULL;
         }
 
@@ -992,6 +992,7 @@ static char *fixup_clipboard_text(SpiceGtkSession *self, const char *text, int *
 
     if (!check_clipboard_size_limits(self, new_len)) {
         g_free(conv);
+        *len = -1;
         return NULL;
     }
 
@@ -1026,6 +1027,9 @@ static void clipboard_received_text_cb(GtkClipboard *clipboard,
 
     /* gtk+ internal utf8 newline is always LF, even on windows */
     conv = fixup_clipboard_text(self, text, &len);
+    if (len == -1) {
+        return;
+    }
 
     spice_main_clipboard_selection_notify(self->priv->main, selection,
                                           VD_AGENT_CLIPBOARD_UTF8_TEXT,
-- 
2.7.4

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://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]