pidgin: 1e846de3: gtkimhtml: Fix handling of pastes whose ...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Sun Apr 18 17:48:51 EDT 2010


-----------------------------------------------------------------
Revision: 1e846de3e179e37fad719788f3929fba6caaf376
Ancestor: 72dd50ad2b172a6559c5632d44c683f6000bb5f2
Author: darkrain42 at pidgin.im
Date: 2010-04-17T21:35:26
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/1e846de3e179e37fad719788f3929fba6caaf376

Modified files:
        ChangeLog pidgin/gtkimhtml.c

ChangeLog: 

gtkimhtml: Fix handling of pastes whose data isn't NULL-terminated

Rich-text pastes from Chrome now work (they failed the g_utf8_validate
far past the end of the paste data) and I bet this also fixes the
URIs-pasted-from-Chrome-have-odd-garbage-at-the-end thing, too.

-------------- next part --------------
============================================================
--- ChangeLog	a2baf076a7d1bbcfe9431e276c1c38f53b465a82
+++ ChangeLog	780d577b9a42023415d38a090fdaf6371c551d28
@@ -45,6 +45,8 @@ version 2.7.0 (??/??/????):
 	  buddy icons.
 	* The 'Message Timestamp Formats' plugin allows changing the timestamp
 	  format from the timestamps' context menu in conversation log.
+	* Fix pastes from Chrome (rich-text pastes and probably URLs
+	  having garbage appended to them)
 
 	Bonjour:
 	* Added support for IPv6. (Thanks to T_X for testing)
============================================================
--- pidgin/gtkimhtml.c	9cb010301b9c7a9dc63755c8a1e758ca46c8ad6f
+++ pidgin/gtkimhtml.c	7829cb59dfb3a3be74e4430f63d7dcadf74128e4
@@ -1185,8 +1185,14 @@ static void paste_received_cb (GtkClipbo
 		printf("\n");
 		}
 #endif
-		text = g_malloc(selection_data->length);
+
+		text = g_malloc(selection_data->length + 1);
 		memcpy(text, selection_data->data, selection_data->length);
+		/* Make sure the paste data is null-terminated.  Given that
+		 * we're passed length (but assume later that it is), this
+		 * seems sensible to me.
+		 */
+		text[selection_data->length] = '\0';
 	}
 
 #ifdef _WIN32


More information about the Commits mailing list