changeset 29747:6eeb50155af8

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.
author Paul Aurich <paul@darkrain42.org>
date Sat, 17 Apr 2010 21:35:26 +0000
parents 0f895633faeb
children 211afed0548b
files ChangeLog pidgin/gtkimhtml.c
diffstat 2 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Apr 17 21:16:19 2010 +0000
+++ b/ChangeLog	Sat Apr 17 21:35:26 2010 +0000
@@ -45,6 +45,8 @@
 	  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)
--- a/pidgin/gtkimhtml.c	Sat Apr 17 21:16:19 2010 +0000
+++ b/pidgin/gtkimhtml.c	Sat Apr 17 21:35:26 2010 +0000
@@ -1185,8 +1185,14 @@
 		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