mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 21:51:08 +00:00
a11y: Avoid a crash
It is not safe to access text[end], if text may not be NUL-terminated. Fixes: #6146
This commit is contained in:
parent
fc4c0f769c
commit
15c43e5284
@ -705,27 +705,19 @@ emit_text_changed (GtkAtSpiContext *self,
|
||||
int end,
|
||||
const char *text)
|
||||
{
|
||||
char *copy = NULL;
|
||||
|
||||
if (self->connection == NULL)
|
||||
return;
|
||||
|
||||
/* Protect against possible non-UTF8 garbage after the end
|
||||
* that g_variant_new_string() will complain about.
|
||||
*/
|
||||
if (text[end] != '\0')
|
||||
text = copy = g_strndup (text, end);
|
||||
|
||||
g_dbus_connection_emit_signal (self->connection,
|
||||
NULL,
|
||||
self->context_path,
|
||||
"org.a11y.atspi.Event.Object",
|
||||
"TextChanged",
|
||||
g_variant_new ("(siiva{sv})",
|
||||
kind, start, end, g_variant_new_string (text), NULL),
|
||||
kind, start, end,
|
||||
g_variant_new_take_string (g_strndup (text, end)),
|
||||
NULL),
|
||||
NULL);
|
||||
|
||||
g_free (copy);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user