mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 02:40:11 +00:00
clipboard: Make sure G_TYPE_STRING is nul-terminated
When reading text, we need to check we terminate the G_TYPE_STRING string with a null byte, because the clipboard does not guarantee one. So just append a \0 to the stream. Fixes #3899
This commit is contained in:
parent
5710df685b
commit
f34e3c573b
@ -672,9 +672,18 @@ string_deserializer_finish (GObject *source,
|
||||
}
|
||||
else
|
||||
{
|
||||
GOutputStream *mem_stream = g_filter_output_stream_get_base_stream (G_FILTER_OUTPUT_STREAM (stream));
|
||||
|
||||
/* write a terminating NULL byte */
|
||||
if (g_output_stream_write (mem_stream, "", 1, NULL, &error) < 0 ||
|
||||
!g_output_stream_close (mem_stream, NULL, &error))
|
||||
{
|
||||
gdk_content_deserializer_return_error (deserializer, error);
|
||||
return;
|
||||
}
|
||||
|
||||
g_value_take_string (gdk_content_deserializer_get_value (deserializer),
|
||||
g_memory_output_stream_steal_data (G_MEMORY_OUTPUT_STREAM (
|
||||
g_filter_output_stream_get_base_stream (G_FILTER_OUTPUT_STREAM (stream)))));
|
||||
g_memory_output_stream_steal_data (G_MEMORY_OUTPUT_STREAM (mem_stream)));
|
||||
}
|
||||
gdk_content_deserializer_return_success (deserializer);
|
||||
}
|
||||
@ -703,7 +712,7 @@ string_deserializer (GdkContentDeserializer *deserializer)
|
||||
|
||||
g_output_stream_splice_async (filter,
|
||||
gdk_content_deserializer_get_input_stream (deserializer),
|
||||
G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE | G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET,
|
||||
G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE,
|
||||
gdk_content_deserializer_get_priority (deserializer),
|
||||
gdk_content_deserializer_get_cancellable (deserializer),
|
||||
string_deserializer_finish,
|
||||
|
Loading…
Reference in New Issue
Block a user