Mercurial > pidgin.yaz
diff pidgin/gtkimhtml.c @ 30159: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 | ffb8cd9fb528 |
children | 211afed0548b |
line wrap: on
line diff
--- 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