Merge branch 'michaelweghorn/a11y_report_empty_string' into 'main'

a11y: Report empty string as such

See merge request GNOME/gtk!6933
This commit is contained in:
Matthias Clasen 2024-02-23 01:06:10 +00:00
commit 4c794505da

View File

@ -80,12 +80,13 @@ nul_terminate_contents (GBytes *bytes)
gsize size;
data = g_bytes_get_data (bytes, &size);
if (size > 0 && data[size - 1] != '\0')
if (size == 0 || (size > 0 && data[size - 1] != '\0'))
{
guchar *copy;
copy = g_new (guchar, size + 1);
memcpy (copy, data, size);
if (size > 0)
memcpy (copy, data, size);
copy[size] = '\0';
g_bytes_unref (bytes);