mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 06:00:22 +00:00
textbuffer: Fix pasting text
The memory stolen from a memory outputstream isn't guaranteed to be 0-terminated, so don't make that assumption. Fixes: #4357
This commit is contained in:
parent
5a42ccc575
commit
5b1b75b055
@ -310,6 +310,7 @@ gtk_text_buffer_deserialize_text_plain_finish (GObject *source,
|
||||
GtkTextIter start, end;
|
||||
GError *error = NULL;
|
||||
gssize written;
|
||||
gsize size;
|
||||
char *data;
|
||||
|
||||
written = g_output_stream_splice_finish (stream, result, &error);
|
||||
@ -319,6 +320,8 @@ gtk_text_buffer_deserialize_text_plain_finish (GObject *source,
|
||||
return;
|
||||
}
|
||||
|
||||
size = g_memory_output_stream_get_size (G_MEMORY_OUTPUT_STREAM (
|
||||
g_filter_output_stream_get_base_stream (G_FILTER_OUTPUT_STREAM (stream))));
|
||||
data = g_memory_output_stream_steal_data (G_MEMORY_OUTPUT_STREAM (
|
||||
g_filter_output_stream_get_base_stream (G_FILTER_OUTPUT_STREAM (stream))));
|
||||
|
||||
@ -326,7 +329,7 @@ gtk_text_buffer_deserialize_text_plain_finish (GObject *source,
|
||||
{
|
||||
buffer = g_value_get_object (gdk_content_deserializer_get_value (deserializer));
|
||||
gtk_text_buffer_get_end_iter (buffer, &end);
|
||||
gtk_text_buffer_insert (buffer, &end, data, -1);
|
||||
gtk_text_buffer_insert (buffer, &end, data, size);
|
||||
gtk_text_buffer_get_bounds (buffer, &start, &end);
|
||||
gtk_text_buffer_select_range (buffer, &start, &end);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user