[Spice-devel] [PATCH spice-gtk] gtk-session: Set value directly

Pavel Grunt pgrunt at redhat.com
Fri Feb 17 12:44:55 UTC 2017


Spotted by coverity
---
 src/spice-gtk-session.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c
index a3a2e90..5688cba 100644
--- a/src/spice-gtk-session.c
+++ b/src/spice-gtk-session.c
@@ -916,25 +916,23 @@ static gboolean check_clipboard_size_limits(SpiceGtkSession *session,
  */
 static char *fixup_clipboard_text(SpiceGtkSession *self, const char *text, int *len)
 {
     char *conv = NULL;
-    int new_len = *len;
 
     if (spice_main_agent_test_capability(self->priv->main, VD_AGENT_CAP_GUEST_LINEEND_CRLF)) {
         conv = spice_unix2dos(text, *len);
-        new_len = strlen(conv);
+        *len = strlen(conv);
     } else {
         /* On Windows, with some versions of gtk+, GtkSelectionData::length
          * will include the final '\0'. When a string with this trailing '\0'
          * is pasted in some linux applications, it will be pasted as <NIL> or
          * as an invisible character, which is unwanted. Ensure the length we
          * send to the agent does not include any trailing '\0'
          * This is gtk+ bug https://bugzilla.gnome.org/show_bug.cgi?id=734670
          */
-        new_len = strlen(text);
+        *len = strlen(text);
     }
 
-    *len = new_len;
     return conv;
 }
 
 static void clipboard_received_text_cb(GtkClipboard *clipboard,
-- 
2.11.1



More information about the Spice-devel mailing list